Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

In Visual Basic 2010, a ListBox is a control used to display a list of items that a user can select from. Each item in the ListBox has a corresponding value that can be used to uniquely identify the item. This value can be a string, a number, or any other data type.

The value of each item in the ListBox can be set using the ValueMember property. This property allows you to specify which property or field of the data source is used as the value for each item in the ListBox. If no ValueMember is specified, the default value is the string representation of the item itself.

When the user selects an item in the ListBox, the value of the selected item can be retrieved using the SelectedValue property. This property returns the value of the currently selected item in the ListBox. Alternatively, you can retrieve the selected index of the ListBox using the SelectedIndex property and use this index to retrieve the corresponding value using the Items collection.

In summary, ListBox and Item Values work in Visual Basic 2010 by assigning a value to each item in the ListBox using the ValueMember property or the default string representation of the item. The value of the selected item can be retrieved using either the SelectedValue property or the SelectedIndex property in combination with the Items collection.