30.07.2013 Views

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 13 Graphical User Interfaces Concepts: Part 2 545<br />

22<br />

23 ' obtain reference of selected item<br />

24 Dim item As String = chklstInput.SelectedItem<br />

25<br />

26 ' if item checked add <strong>to</strong> listbox<br />

27 ' otherwise remove from listbox<br />

28 If e.NewValue = CheckState.Checked Then<br />

29 lstDisplay.Items.Add(item)<br />

30 Else<br />

31 lstDisplay.Items.Remove(item)<br />

32 End If<br />

33<br />

34 End Sub ' chklstInput_ItemCheck<br />

35<br />

36 End Class ' FrmCheckedListBox<br />

Fig. 13.14 CheckedListBox and ListBox used in a program <strong>to</strong> display a user<br />

selection (part 2 of 2).<br />

13.5 ComboBoxes<br />

The ComboBox control combines TextBox features with a drop-down list. A drop-down<br />

list is a GUI component that contains a list from which a value can be selected. It usually<br />

appears as a text box with a down arrow <strong>to</strong> its right. By default, the user can enter text in<strong>to</strong><br />

the text box or click the down arrow <strong>to</strong> display a list of predefined items. If a user chooses<br />

an element from this list, that element is displayed in the text box. If the list contains more<br />

elements than can be displayed in the drop-down list, a scrollbar appears. The maximum<br />

number of items that a drop-down list can display at one time is set by property MaxDrop-<br />

DownItems. Figure 13.15 shows a sample ComboBox in three different states.<br />

As with the ListBox control, the programmer can add objects <strong>to</strong> collection Items<br />

programmatically, using methods Add and AddRange, or visually, with the String Collection<br />

Edi<strong>to</strong>r. Figure 13.16 lists common properties and events of class ComboBox.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!