Lab 6
ListBoxes
First: Review listBox control item and its main properties, methods and
default event.
Create the following form, and add a Listbox with the following items in it:
- Review the property SelectionMode and change its value (One,
MultiSimple, MultiExtended)
- Change the property Sorted into True, and check the effect.
- Add two labels to the form.
- In the first label, display the selectedItem (use the default event
SelectedIndexChanged).
- In the second label, display the selectedIndex. (check its value when no
items are selected)
- Discuss the properties SelectedItems and SelectedIndecies.
- If a user selects either C++ or C#, display a message "Welcome to C
languages". (hint: use method GetSelected)
1
- Add a button labeled "Count" and another label. When pressing the
button, display number of items in the listbox in the new label.
Second: Practice several actions on the listBox.
Create the following form:
Activate the displayed buttons as follows:
1. Add: Adds the item entered in the textbox into the listbox.
2. Remove: Removes the selected item in the listbox (Ex: Change it to
remove the written item in the textbox).
3. Clear List: Clears/removes all items in the listbox
4. Clear Selected: Removes the selection on items in the listbox.
2
Exercise 5:
Create the following form:
Activate the displayed buttons, so that:
1. > : moves the selected item from left listbox to the right one.
2. <: moves the selected item from right listbox to the left one
3. >>: moves all items from left listbox to the right one.
4. <<: moves all items from right listbox to the left one.
Change the code in > and < buttons, so that they move the selected
items.