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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

None and One. One allows multiple selection, because checkboxes imply that there are no<br />

logical restrictions on the items—the user can select as many items as required. Thus, the<br />

only choice is whether <strong>to</strong> give the user multiple selection or no selection at all. This keeps<br />

the CheckedListBox’s behavior consistent with that of CheckBoxes. The programmer<br />

is unable <strong>to</strong> set the last two SelectionMode values, MultiSimple and Multi-<br />

Extended, because the only logical two selection modes are handled by None and One.<br />

Common properties and events of CheckedListBoxes appear in Fig. 13.13.<br />

Common <strong>Program</strong>ming Error 13.1<br />

The IDE displays an error message if the programmer attempts <strong>to</strong> set the SelectionMode<br />

property <strong>to</strong> MultiSimple or MultiExtended in the Properties window of a<br />

CheckedListBox; If this value is set programmatically, a runtime error occurs. 13.1<br />

Event ItemCheck is generated whenever a user checks or unchecks a<br />

CheckedListBox item. Event argument properties CurrentValue and NewValue<br />

return CheckState values for the current and new state of the item, respectively. A comparison<br />

of these values allows the programmer <strong>to</strong> determine whether the<br />

CheckedListBox item was checked or unchecked. The CheckedListBox control<br />

retains the SelectedItems and SelectedIndices properties (it inherits them from<br />

class ListBox). <strong>How</strong>ever, it also includes properties CheckedItems and Checked-<br />

Indices, which return information about the checked items and indices.<br />

CheckedListBox<br />

properties, methods<br />

and events Description / Delegate and Event Arguments<br />

Common Properties (All the ListBox properties and events are inherited by<br />

CheckedListBox.)<br />

CheckedItems Contains the collection of items that are checked. This is distinct from<br />

the selected item, which is highlighted (but not necessarily checked).<br />

[Note: There can be at most one selected item at any given time.]<br />

CheckedIndices Returns indices for all checked items. This is not the same as the<br />

selected index.<br />

SelectionMode Determines how many items can be checked. Only possible values are<br />

One (allows multiple checks <strong>to</strong> be placed) or None (does not allow any<br />

checks <strong>to</strong> be placed).<br />

Common Method<br />

GetItemChecked Takes an index and returns True if the corresponding item is checked.<br />

Common Event (Delegate ItemCheckEventHandler, event arguments Item-<br />

CheckEventArgs)<br />

ItemCheck Generated when an item is checked or unchecked.<br />

ItemCheckEventArgs Properties<br />

CurrentValue Indicates whether the current item is checked or unchecked. Possible<br />

values are Checked, Unchecked and Indeterminate.<br />

Fig. 13.13 CheckedListBox properties, methods and events (part 1 of 2).

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

Saved successfully!

Ooh no, something went wrong!