MAKING SELECTIONS

Selection controls enable the user to choose values. If you use them carefully, you can reduce the chances of the user making an invalid selection, so you can reduce the amount of error-handling code you need to write.

The following table briefly describes the WPF controls that allow the user to select choices.

CONTROL PURPOSE
CheckBox Lets the user select an item or not. Each CheckBox choice is independent of all others.
ComboBox Displays items in a drop-down list. ComboBoxItem controls contain the items displayed in the list. (See example program UseComboBox, available for download on the book’s website.)
ComboBoxItem1 Holds the content for one ComboBox item.
ListBox Displays items in a list. ListBoxItem controls contain the items displayed in the list. The control automatically displays scroll bars when needed. (See example program UseListBox, available for download on the book’s website.)
ListBoxItem1 Holds the content for one ListBox item.
RadioButton Lets the user pick from among a set of options. If the user checks one RadioButton, all others with the same parent become unchecked. (See example program UseRadioButtons, available for download on the book’s website.)
ScrollBar Allows the user to drag a “thumb” to select a numeric value. Usually scroll bars are used internally by other controls such as the ScrollViewer, and your applications should use a Slider instead. (See example program UseScrollBar, available for download on the book’s ...

Get Visual Basic 2012 Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.