ListBox Object - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

ListBox Object

Description:

ListBoxes. Displays a group of values, called items, with one item per line. ... Add a button to your form. Declare a string variable to read in clothing stores. ... – PowerPoint PPT presentation

Number of Views:121
Avg rating:3.0/5.0
Slides: 10
Provided by: bcps1
Category:
Tags: listbox | object

less

Transcript and Presenter's Notes

Title: ListBox Object


1
ListBox Object
2
ListBoxes
  • Displays a group of values, called items, with
    one item per line.
  • Open a new VB application, place a ListBox onto
    the form.
  • Name the ListBox lstClothingStores

3
Displaying Data Using the ListBox Object
4
Coding a ListBox
  • Add a button to your form.
  • Declare a string variable to read in clothing
    stores.
  • Assign the values from an InputBox to your string
    variable to read in the stores.
  • Output the stores into the ListBox using
    lstClothingStores.Items.Add(str)

5
Clearing a ListBox
  • You can clear the ListBox the same way you clear
    a TextBox.
  • Add a MenuStrip to your form with a clear option
    to clear the ListBox.

6
Adding Items During Design
  • Sometimes you want to have items already in a
    list box.
  • Add items to your list box in the Items property
    in the Properties window.
  • Add 5 stores, pressing Enter after each store.

7
Selecting Items
  • The SelectedItem property identifies which item
    in the ListBox is selected.

8
Outputting Selected Item
  • You can output the selected item to a MessageBox.

9
Assignment
  • Create a form with a ListBox and a MenuStrip.
    Code a Clear and Exit item under the File menu.
  • Have the user enter 5 of their favorite bands
    into the list box during runtime. (Use an
    InputBox or TextBox)
  • Have the user select the band they want to listen
    to presently and output their selection in a
    MessageBox.
Write a Comment
User Comments (0)
About PowerShow.com