Export (0) Print
Expand All
Expand Minimize

ListBox Control Changes in Visual Basic .NET

The ListBox control in Visual Basic 6.0 is replaced by either the Windows Forms ListBox control or the CheckedListBox control in Visual Basic .NET. The names of some properties, methods, events, and constants are different, and in some cases there are differences in behavior.

During upgrade, if the Style property of a Visual Basic 6.0 Listbox is set to 1 – Checkbox, it is upgraded to the CheckedListBox control; otherwise, it is upgraded to the ListBox control.

The following tables list Visual Basic 6.0 properties, methods, and events and their Visual Basic .NET equivalents. Where applicable, constants are indented beneath the property or method. All Visual Basic .NET constants map to the System.Windows.Forms namespace unless otherwise noted.

Links are provided as necessary to topics explaining differences in behavior. Where there is no direct equivalent in Visual Basic .NET, links are provided to topics that present alternatives.

ListBox Properties

Visual Basic 6.0Visual Basic .NET Equivalent
AppearanceNo equivalent. For more information, see Appearance and BorderStyle Property Changes in Visual Basic .NET.
BackColor
BackColor
Note   Colors are handled differently in Visual Basic .NET. For more information, see Color Behavior Changes in Visual Basic .NET.
For a list of constants, see Color Changes in Visual Basic .NET.
CausesValidationCausesValidation
ColumnsMultiColumn and ColumnWidth
Note   The Columns property took an integer specifying the number of columns. The MultiColumn property takes a Boolean value, and the ColumnWidth property takes an integer specifying the width in pixels. If the width of the ListBox control is changed at run time, you may also need to set the ColumnWidth property for each column.
ContainerParent
DataChangedNo equivalent. For more information, see Data Changes in Visual Basic .NET.
DataFieldNo equivalent. For more information, see Data Changes in Visual Basic .NET.
DataFormatNo equivalent. For more information, see Data Changes in Visual Basic .NET.
DataMemberNo equivalent. For more information, see Data Changes in Visual Basic .NET.
DataSourceNo equivalent. For more information, see Data Changes in Visual Basic .NET.
DragIconNo equivalent. For more information, see Drag and Drop Changes in Visual Basic .NET.
DragModeNo equivalent. For more information, see Drag and Drop Changes in Visual Basic .NET.
EnabledEnabled
FontFont
Note   Fonts are handled differently in Visual Basic .NET. For more information, see Font Changes in Visual Basic .NET.
FontBoldFont
Note   Fonts are handled differently in Visual Basic .NET. For more information, see Font Changes in Visual Basic .NET.
FontItalicFont
Note   Fonts are handled differently in Visual Basic .NET. For more information, see Font Changes in Visual Basic .NET.
FontNameFont
Note   Fonts are handled differently in Visual Basic .NET. For more information, see Font Changes in Visual Basic .NET.
FontSizeFont
Note   Fonts are handled differently in Visual Basic .NET. For more information, see Font Changes in Visual Basic .NET.
FontStrikethruFont
Note   Fonts are handled differently in Visual Basic .NET. For more information, see Font Changes in Visual Basic .NET.
FontUnderlineFont
Note   Fonts are handled differently in Visual Basic .NET. For more information, see Font Changes in Visual Basic .NET.
ForeColor
ForeColor
Note   Colors are handled differently in Visual Basic .NET. For more information, see Color Behavior Changes in Visual Basic .NET.
For a list of constants, see Color Changes in Visual Basic .NET.
HeightHeight, Size
Note   Coordinates are handled differently in Visual Basic .NET. For more information, see Coordinate System Changes in Visual Basic .NET.
HelpContextIDNo equivalent. For more information, see Help Support Changes in Visual Basic .NET.
HWndHandle
IndexNo equivalent. For more information, see Control Array Changes in Visual Basic .NET.
IntegralHeightIntegralHeight
ItemDataNo equivalent. For more information, see ItemData property cannot be upgraded.
LeftLeft
Note   Coordinates are handled differently in Visual Basic .NET. For more information, see Coordinate System Changes in Visual Basic .NET.
ListItems
ListCountItems.Count
ListIndexSelectedIndex
MouseIconNo equivalent. For more information, see Cannot set a custom MousePointer.
MousePointerCursor

For a list of constants, see MousePointer Changes in Visual Basic .NET.

MultiSelect
0 – None

1 – Simple

2 – Extended

SelectionMode
SelectionMode.One

SelectionMode.MultiSimple

SelectionMode.MultiExtended

NameName
NewIndexNo equivalent. For more information, see NewIndex property cannot be upgraded.
OLEDragModeNo equivalent. For more information, see Drag and Drop Changes in Visual Basic .NET.
OLEDropModeNo equivalent. For more information, see Drag and Drop Changes in Visual Basic .NET.
ParentFindForm method
RightToLeft
True

False

RightToLeft
RightToLeft.Yes

RightToLeft.No

SelCountSelectedItems.Count
SelectedGetSelected, SetSelected (ListBox control)

GetItemChecked, SetItemChecked (CheckedListBox control)

SortedSorted
Style
0 - Standard

1 - Checkbox

No equivalent property. 0 – Standard maps to the ListBox control, 1 – Checkbox maps to the CheckedListBox control.
TabIndexTabIndex
TabStopTabStop
TagTag
TextText
ToolTipTextToolTip component

For more information, see ToolTip Changes in Visual Basic .NET.

TopTop
Note   Coordinates are handled differently in Visual Basic .NET. For more information, see Coordinate System Changes in Visual Basic .NET.
TopIndexTopIndex
VisibleVisible
WhatsThisHelpIDNo equivalent. For more information, see Help Support Changes in Visual Basic .NET.
WidthWidth, Size
Note   Coordinates are handled differently in Visual Basic .NET. For more information, see Coordinate System Changes in Visual Basic .NET.

ListBox Methods

NameVisual Basic .NET Equivalent
AddItemItems.Insert or

Items.Add

ClearItems.Clear
DragNo equivalent. For more information, see Drag and Drop Changes in Visual Basic .NET.
MoveSetBounds
Note   Coordinates are handled differently in Visual Basic .NET. For more information, see Coordinate System Changes in Visual Basic .NET.
OLEDragNo equivalent. For more information, see Drag and Drop Changes in Visual Basic .NET.
RefreshRefresh
RemoveItemItems.Remove
SetFocusFocus
ShowWhatsThisNo equivalent. For more information, see Help Support Changes in Visual Basic .NET.
ZOrder
0 – vbBringToFront

1 - vbSendToBack

BringToFront() or SendToBack() functions
BringToFront()

SendToBack()

ListBox Events

Visual Basic 6.0Visual Basic .NET Equivalent
ClickSelectedIndexChanged
Note   In Visual Basic 6.0, the Click event was raised when the CheckBox state was changed programmatically. In Visual Studio .NET, the Click event is not raised; therefore, you should use the CheckStateChanged event.
DblClickNo equivalent. Use the SelectedIndexChanged or TextChanged events.
DragDropNo equivalent. For more information, see Drag and Drop Changes in Visual Basic .NET.
DragOverNo equivalent. For more information, see Drag and Drop Changes in Visual Basic .NET.
GotFocusEnter
ItemCheckItemCheck (CheckedListBox only)
Note   In Visual Basic 6.0, when an event was raised, the check state was already changed. In Visual Basic .NET, the check state has not yet changed. You can get the pending value from the ItemCheckEventArgs argument passed to the event.
KeyDownKeyDown
KeyPressKeyPress
KeyUpKeyUp
LostFocusLeave
MouseDownMouseDown
MouseMoveMouseMove
MouseUpMouseUp
OLECompleteDragNo equivalent. For more information, see Drag and Drop Changes in Visual Basic .NET.
OLEDragDropNo equivalent. For more information, see Drag and Drop Changes in Visual Basic .NET.
OLEDragOverNo equivalent. For more information, see Drag and Drop Changes in Visual Basic .NET.
OLEGiveFeedbackNo equivalent. For more information, see Drag and Drop Changes in Visual Basic .NET.
OLESetDataNo equivalent. For more information, see Drag and Drop Changes in Visual Basic .NET.
OLEStartDragNo equivalent. For more information, see Drag and Drop Changes in Visual Basic .NET.
ScrollNo equivalent. For more information, see TopIndex Property and Scroll Event Changes in Visual Basic .NET.
ValidateValidating

See Also

Introduction to the Windows Forms ListBox Control

Show:
© 2014 Microsoft