Label Control for Visual Basic 6.0 Users
This topic compares the Visual Basic 6.0 Label control with its equivalent in Visual Basic 2008.
The Label control in Visual Basic 6.0 is replaced by the Windows Forms Label control in Visual Basic 2008. The names of some properties, methods, events, and constants are different, and in some cases there are behavior differences.
Conceptual Differences
BackStyle Property
In Visual Basic 6.0, the BackStyle property of the Label control determines whether the label had a transparent background. Setting the BackStyle property to 0 – Transparent allows any background image to show through the label. If the label is placed over other controls, the controls also show through.
In Visual Basic 2008, the BackStyle property no longer exists and the transparency behavior is slightly different. To emulate the transparent behavior in Visual Basic 2008, set the BackColor property to Transparent. This will allow the background image to show through. If the label is placed over other controls, the controls will show through only if they are higher in the z-order.
Note
The ZOrder method no longer exists in Visual Basic 2008. At design time you can use the Bring to Front or Send to Back command on the Format menu; at run time you can use the BringToFront or SendToBack function.
WordWrap Property
In Visual Basic 6.0, the WordWrap property determines if text wraps to multiple lines when it is too long to fit in a label.
In Visual Basic 2008, the text in a Label control automatically wraps. The only way to prevent wrapping is to make the height of the Label control equivalent to a single line of text.
Other Differences
In addition, there are numerous conceptual differences that apply to all controls, including differences in data binding, font handling, drag-and-drop functionality, Help support and more. For more information, see Windows Forms Concepts for Visual Basic 6.0 Users.
Code Changes for the Label Control
The following code example illustrates the differences in coding techniques between Visual Basic 6.0 and Visual Basic 2008.
Code Changes for Making a Label Transparent
The following example demonstrates making the background of a label control transparent. In Visual Basic 6.0, if there are other controls behind the Label, those controls show through. In the Visual Basic 2008 example, any controls behind the Label can optionally show through using the BringToFront and SendToBack functions.
' Visual Basic 6.0
Private Sub MakeTransparent()
Label1.BackStyle = vbTransparent
End Sub
' Visual BasicPrivateSub MakeTransparent()
Label1.BackColor = System.Drawing.Color.Transparent
' Let controls behind the label show through.
Label1.SendToBack()
' Make the portion of controls behind the label transparent
Label1.BringToFront()
EndSub
Label Control Property, Method, and Event Equivalencies
The following tables list Visual Basic 6.0 properties, methods, and events, along with their Visual Basic 2008 equivalents. Those properties, methods, and events that have the same name and behavior are not listed. Where applicable, constants are indented beneath the property or method. All Visual Basic 2008 enumerations map to the System.Windows.Forms namespace unless otherwise noted.
This table provides necessary links to topics explaining behavior differences. Where there is no direct equivalent in Visual Basic 2008, links are provided to alternatives.
Label Properties
Visual Basic 6.0 |
Visual Basic 2008 Equivalent |
---|---|
Alignment: 0 - Left Justify 1 - Right Justify |
MiddleLeft enumeration value MiddleRight enumeration value |
Appearance |
New implementation. For more information, see Appearance and BorderStyle Properties for Visual Basic 6.0 Users. |
AutoSize |
|
BackColor |
Note For a list of constants, see Color Handling for Visual Basic 6.0 Users.
Note:
Colors are handled differently in Visual Basic 2008. For more information, see Color Behavior for Visual Basic 6.0 Users.
|
BackStyle |
New implementation. For more information, see Conceptual Differences above. |
Caption |
|
Container |
|
DataChanged DataField DataFormat DataMember DataSource |
New implementation. For more information, see Data Access for Visual Basic 6.0 Users. |
DragIcon DragMode |
New implementation. For more information, see Drag and Drop for Visual Basic 6.0 Users. |
Font FontBold FontItalic FontName FontSize FontStrikethrough FontUnderline |
Note Fonts are handled differently in Visual Basic 2008. For more information, see Font Handling for Visual Basic 6.0 Users. |
ForeColor |
Note:
For a list of constants, see Color Handling for Visual Basic 6.0 Users.
Note:
Colors are handled differently in Visual Basic 2008. For more information, see Color Behavior for Visual Basic 6.0 Users.
|
Height |
Note:
Coordinates are handled differently in Visual Basic 2008. For more information, see Coordinate System for Visual Basic 6.0 Users.
|
Index |
New implementation. For more information, see Control Arrays for Visual Basic 6.0 Users. |
Left |
Note:
Coordinates are handled differently in Visual Basic 2008. For more information, see Coordinate System for Visual Basic 6.0 Users.
|
LinkItem LinkMode LinkTimeOut LinkTopic |
No equivalent. For more information, see Dynamic Data Exchange for Visual Basic 6.0 Users. |
MouseIcon |
New implementation. For more information, see Cannot set a custom MousePointer. |
MousePointer |
For a list of constants, see MousePointer for Visual Basic 6.0 Users. |
OLEDropMode |
New implementation. For more information, see Drag and Drop for Visual Basic 6.0 Users. |
Parent |
FindForm method |
RightToLeft: True False |
Yes enumeration value No enumeration value |
ToolTipText |
ToolTip component For more information, see ToolTip Support for Visual Basic 6.0 Users. |
Top |
Note:
Coordinates are handled differently in Visual Basic 2008. For more information, see Coordinate System for Visual Basic 6.0 Users.
|
WhatsThisHelpID |
New implementation. For more information, see Help Support for Visual Basic 6.0 Users. |
Width |
Note:
Coordinates are handled differently in Visual Basic 2008. For more information, see Coordinate System for Visual Basic 6.0 Users.
|
WordWrap |
New implementation.
Note:
Text in the Visual Basic 2008 Label control wraps by default and cannot be changed.
|
Label Methods
Visual Basic 6.0 |
Visual Basic 2008 Equivalent |
---|---|
Drag |
New implementation. For more information, see Drag and Drop for Visual Basic 6.0 Users. |
LinkExecute LinkPoke LinkRequest LinkSend |
No equivalent. For more information, see Dynamic Data Exchange for Visual Basic 6.0 Users. |
Move |
Note:
Coordinates are handled differently in Visual Basic 2008. For more information, see Coordinate System for Visual Basic 6.0 Users.
|
OLEDrag |
New implementation. For more information, see Drag and Drop for Visual Basic 6.0 Users. |
ShowWhatsThis |
New implementation. For more information, see Help Support for Visual Basic 6.0 Users. |
ZOrder: 0 – vbBringToFront 1 - vbSendToBack |
BringToFront or SendToBack method |
Label Events
Visual Basic 6.0 |
Visual Basic 2008 Equivalent |
---|---|
Change |
|
DblClick |
|
DragDrop DragOver |
New implementation. For more information, see Drag and Drop for Visual Basic 6.0 Users. |
LinkClose LinkError LinkNotify LinkOpen |
No equivalent. For more information, see Dynamic Data Exchange for Visual Basic 6.0 Users. |
OLECompleteDrag OLEDragDrop OLEDragOver OLEGiveFeedback OLESetData OLEStartDrag |
New implementation. For more information, see Drag and Drop for Visual Basic 6.0 Users. |
Upgrade Notes
When a Visual Basic 6.0 application is upgraded to Visual Basic 2008, any Label controls are upgraded to Windows Forms Label controls, and properties, methods and events are upgraded to their equivalent. Where there may be differences in behavior, upgrade comments are inserted into the code.