Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab4 ListBox Control Properties, Methods and Events.

Similar presentations


Presentation on theme: "Lab4 ListBox Control Properties, Methods and Events."— Presentation transcript:

1 Lab4 ListBox Control Properties, Methods and Events

2 List Box An input box that displays a list of items from which a user can make the selection. Initializing the list box 1. You can initialize such list boxes from the List property (Design-time). 2. Initializing list boxes using procedures (run-time).

3 List Box Methods Additem: Adds an item to the listbox. lstBox.AddItem str RemoveItem : Removes one item from the list box. The statement lstBox.RemoveItem n deletes the item of index n from lstBox, the statement Clear : Removes all items from the listbox. lstBox.Clear

4 List Box Properties List: The string array lstBox.List( ) holds the list of items stored in the list box. In particular, the value of lstBox.List(n) is the item of lstBox having index n. ListIndex: The index of the selected listbox item,Starts from 0. The value of lstBox.ListIndex is the index number of the item currently highlighted in lstBox. (If no item is highlighted, the value of ListIndex is –1.)

5 List Box Properties ListCount: The number of the list items. Text: specifies the list box’s selected item. the value of lstBox.Text is also the currently highlighted item. Sorted: True/False Specifies whether or not the list box items are sorted

6 List Box Properties The value of lstBox.List(lstBox.ListIndex) is the item (string) currently highlighted in lstBox. NewIndex: The value of lstBox.NewIndex is the index number of the item most recently added to lstBox by the AddItem method.

7 Multiselection ListBox To select more than one item from a list box, you can do so after handling some properties like style, multiselection. Style (Design-time): 0: Specifies a standard ListBox style (Default). 1: Specifies a ListBox with CheckBox in front of each item. How can you Select/Deselect from this ListBox? You can do so by pointing to the item ( using the mouse or up and down arrows), then choosing the item( Click the mouse or the spaces bar)

8 Multiselect (Design-Time): 0 (None): Multiple selection not allowed. 1(Simple): Allows multiple selection. 2: (Extended): Allows multiple selection Holding the Shift key and selecting an item selects all selections between the last selection and the current selection. Important Note: When Multiselect property > 0, Style property should be 0

9 Selected (Run-Time): –True: The item is selected. –False: the item is deselected. Example: Print ListName.Selected(ListIndex) The result should be : True/False. Note: You can use this property in a loop to know what items are selected from the list.


Download ppt "Lab4 ListBox Control Properties, Methods and Events."

Similar presentations


Ads by Google