0% found this document useful (0 votes)
11 views

03. Exploring the Visual C# Toolbox (part 3)

Uploaded by

PoEnya RaTna
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

03. Exploring the Visual C# Toolbox (part 3)

Uploaded by

PoEnya RaTna
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Business

Application
Programming
LISTBOX, CHECKEDLISTBOX, AND COMBOBOX
CONTROLS
Overview

ListBox, CheckedListBox, and ComboBox objects all allow users to select


choices from a list. The three classes descend from ListControl. Of course, they
are also Controls and so inherit properties such as Text and BackColor from the
Control class. Other properties are more specific to list-type objects.
Common ListBox properties
Property or Method Description
Items The collection of items in the ListBox; frequently, these are strings, but they can also be
other types of objects.
MultiColumn Indicates whether display can be in multiple columns.
SelectedIndex Returns the index of the selected item. If no item has been selected, the value is –1.
Otherwise, it is a value from 0 through n – 1, where n is the number of items in the
ListBox.
SelectedIndices Returns a collection of all the selected indices (when SelectionMode is more than One).

SelectedItem Returns a reference to the selected item.


SelectedItems Returns a collection of the selected items (when SelectionMode is more than One).

SelectionMode Determines how many items can be selected.


Sorted Sorts the items when set to true.
SelectedIndexChanged() Default event that is generated when the selected index changes.
ListBox

A list box displays a list of items from which the user


can select by clicking.
After you drag a ListBox onto a Form, you can select its
Items property and type a list into a String Collection
Editor.
ListBox
•With a ListBox, you allow the user to make a single selection or multiple
selections by setting the SelectionMode property appropriately. For example,
when the SelectionMode property is set to One, the user can make only a
single selection from the ListBox.
•When the SelectionMode is set to MultiExtended, pressing Shift and clicking the
mouse or pressing Shift and one of the arrow keys (up, down, left, or right)
extends the selection to span from the previously selected item to the current
item.
•Pressing Ctrl and clicking the mouse selects or deselects an item in the list.
ListBox
ListBox
when you size a ListBox so that all the items cannot be displayed at the
same time, a scroll bar is provided automatically on the side.

The ListBox also provides the Boolean MultiColumn property, which you
can set to display items in columns instead of a straight vertical list.

This approach allows the control to display more items and can eliminate
the need for the user to scroll down to an item.
ListBox

A ListBox with a scroll A multicolumn


bar ListBox
CheckedListBox

A CheckedListBox is also similar to a


ListBox, with check boxes appearing to
the left of each desired item.
ComboBox

A combo box is a combination of a list


box and and an editing control that
allows a user to select from the list or to
enter new text.
The C# class is ComboBox, and the
default ComboBox displays an editing
area with a hidden list box.
ComboBox

A combo box is a combination of a list


box and and an editing control that
allows a user to select from the list or to
enter new text.
The C# class is ComboBox, and the
default ComboBox displays an editing
area with a hidden list box.
MessageBox
A message box is a dialog box that is used to quickly display information and
optionally allow users to make decisions.
Access to the message box is provided by the MessageBox class.
A message box is displayed modally. And the code that displays the message box
is paused until the user closes the message box either with the close button or a
response button.

• A title bar with a caption (1).


• A close button (2).
• Icon (3).
• Message displayed to the user (4).
• Response buttons (5).
MessageBox
Learn more about MessageBox :
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/windows/how-to-open-message-box?vi
ew=netdesktop-8.0

Try by yourself:
https://youtu.be/c5RBsIdud10?si=nxY-prugTT601qCW
Question &
Answers

You might also like