ListBox Control

A ListBox control displays a list of items from which the user can select one or more. If the number of items exceeds the number that can be displayed, a scroll bar is automatically added to the ListBox control.

If no item is selected, the ListIndex property value is –1. The first item in the list is ListIndex 0, and the value of the ListCount property is always one more than the largest ListIndex value.

Syntax

ListBox

The ListBox control has the following properties, methods, and events.

Properties Methods Events
Appearance AddItem Click
BackColor, ForeColor Clear DblClick
Columns Move GotFocus
Container Refresh ItemCheck
Enabled RemoveItem KeyDown, KeyUp
Font SetFocus KeyPress
FontBold ZOrder LostFocus
FontItalic MouseDown, MouseUp
FontStrikethru MouseMove
FontUnderline Scroll
FontName
FontSize
Height, Width
HWnd
ItemData
Left, Top
List
ListCount
ListIndex
MultiSelect
Name
NewIndex
Parent
SelCount
Selected
Sorted
Style
TabIndex
TabStop
Tag
Text
TopIndex
Visible

Remarks

To add or delete items in a ListBox control, use the AddItem or RemoveItem method. Set the List, ListCount, and ListIndex properties to enable a user to access items in the ListBox. Alternatively, you can add items to the list by using the List property at design time.