Presentation is loading. Please wait.

Presentation is loading. Please wait.

List-based Controls. Slide 2 Introduction There are several controls that work with lists ComboBox ListBox CheckedListBox.

Similar presentations


Presentation on theme: "List-based Controls. Slide 2 Introduction There are several controls that work with lists ComboBox ListBox CheckedListBox."— Presentation transcript:

1 List-based Controls

2 Slide 2 Introduction There are several controls that work with lists ComboBox ListBox CheckedListBox

3 Slide 3 The ComboBox Control (1) It contains a list of items Items can be populated at run-time or at design-time The SelectedIndexChanged event fires when the user selects an item The SelectedIndex property contains the 0-based index of the selected item The SelectedItem property contains the text that the user sees

4 Slide 4 The ComboBox Control (2) The DropDownStyle property controls how the list drops-down, and whether the box is editable Count contains the number of items in the list Adding and removing items works the same way as any collection Add, Insert, Clear, Remove

5 Slide 5 The ComboBox Control Adding items at design-time Set the Items property using the String Collection Editor

6 Slide 6 The ComboBox Control Adding items at run-time Call the Add method of the Items collection Example for (int x = 2010; x < 2016; x++) { cboSelectYear.Items.Add(x.ToString()); }

7 Slide 7 The ListBox Control (1) It’s really a ComboBox that does not drop- down Most of the properties work the same way Set the SelectionMode property to select one or many items One, MultiSimple, MultiExtended Call GetSelected and SetSelected to determine whether an item is selected or to select an item

8 Slide 8 The CheckedListBox Control It’s really just a ListBox control


Download ppt "List-based Controls. Slide 2 Introduction There are several controls that work with lists ComboBox ListBox CheckedListBox."

Similar presentations


Ads by Google