Professional Documents
Culture Documents
(3rd Week)
Information Technology, Engineering Faculty
UNIM
2.
3.
4.
Drop-down lists
nd operate similarly
Combo box control has a DropDownStyle property to determin
e if list box has a text box for user entry and whether list will dro
p down
Filling a List
Click on ellipses button next to Items property to open String C
ollection Editor
Use String Collection Editor to add items to list
To add items during execution, use the Items.Add or Items.Inse
rt method
General Form
Object.Items.Add(ItemValue);
New item added to end of the list
coffeeComboBox.Items.Add(coffeeComboBox.Text);
Object.Items.Insert(IndexPosition, ItemValue);
Index is zero based
Do not set the list controls Sorted property to true if using the I
nsert method
Example:
schoolsListBox.Items.Insert(0,Harvard);
Example:
coffeeTypesListBox.SelectedIndex = 3;
intTotalItems = itemsListBox.Items.Count;
strSelectedFlavor = FlavorListBox.Items(FlavorListBox.SelectedIndex)
Object.Items.RemoveAt(IndexPosition)
Use Items.Remove method to remove by text
General Form
Object.Items.Remove(TextString)
Clearing a List
Use Items.Clear method to empty a combo box or list box
General Form
Object.Items.Clear()
Example:
schoolsListBox.Items.Clear()
7- 12
Clearing a List
Use Items.Clear method to empty a combo box or list box
General Form
Object.Items.Clear()
Example:
schoolsListBox.Items.Clear()
7- 13
Exercise
Finish!