ToolBar Control for Visual Basic 6.0 Users
The ToolBar control in Visual Basic 6.0 is replaced by the ToolStrip control in Visual Basic 2008. The names of some properties, methods, events, and constants are different, and in some cases there are differences in behavior.
Conceptual Differences
The Visual Basic 6.0 ToolBar control is an ActiveX control that is used to create simple toolbars with buttons and combo boxes.
You can use the Visual Basic 2008 ToolStrip control to create customized toolbars and user-interface elements or to create toolbars and user-interface elements that have the appearance and behavior of Microsoft Windows XP, Microsoft Office, or Microsoft Internet Explorer. These user-interface elements support overflow and run-time item reordering. ToolStrip controls offer a rich design-time experience that includes in-place activation and editing, custom layout, and rafting, which is the ability of toolbars to share horizontal or vertical space.
Note
Visual Basic 2008 also has a ToolBar control that is carried over from earlier versions; however the ToolStrip control is the recommended choice because of its advanced capabilities.
AllowCustomize Property, Customize Method, Change Event
In Visual Basic 6.0, the AllowCustomize property of a ToolBar control can be used to display a standard Customize Toolbar dialog box, which allows the user to hide, display, or rearrange toolbar buttons. The Customize method can be used to invoke the dialog box programmatically. The Change event is raised when the user closes the Customize Toolbox dialog box.
The Visual Basic 2008 ToolStrip control has no equivalent property or method; you must create your own dialog box and display it using the ShowDialog method. For more information, see ToolStrip Customizing Sample.
DisabledImageList, HotImageList, ImageList Properties
In Visual Basic 6.0, the DisabledImageList, HotImageList and ImageList properties of a ToolBar control are used to associate the control with ImageList controls. Separate images can be associated for different states: normal (ImageList), disabled (DisabledImageList), and selected (HotImageList).
The Visual Basic 2008 ToolStrip control has no equivalent properties. The ToolStripButton object has a single Image property; setting the Enabled property of the ToolStripButton to False automatically renders the image disabled. To emulate the Visual Basic 6.0 "selected" state behavior, you can either assign a different image or change the BackColor property of the ToolStripButton at run time.
Style Property
In Visual Basic 6.0, the Style property of a ToolBar control determines where images are displayed in relationship to text; setting it to tbrTransparent also enables hot tracking.
The Visual Basic 2008 ToolStrip control has no equivalent property. The relationship between image and text is controlled by setting the TextImageAlign property of the ToolStripItem; unlike Visual Basic 6.0, each item can have a different alignment. Hot tracking is not directly supported, but you can emulate the behavior by changing the Image property in the MouseEnter and MouseLeave events.
Wrappable Property
In Visual Basic 6.0, the Wrappable property of a ToolBar control determines whether the toolbar buttons will automatically wrap when the window is resized.
The Visual Basic 2008 ToolStrip control has no direct equivalent; it supports the use of a dropdown overflow menu instead. When you add ToolStripItem elements that require more space than is allotted to the ToolStrip, given the form's current size, a ToolStripOverflowButton automatically appears on the ToolStrip. The ToolStripOverflowButton appears, and overflow-enabled items are moved into the drop-down overflow menu. You can disable this behavior by setting the CanOverflow property to False.
In addition, you can specify the overflow behavior for an individual ToolStripItem element by setting its Overflow property. For more information, see How to: Manage ToolStrip Overflow in Windows Forms.
RestoreToolBar, SaveToolBar Methods
In Visual Basic 6.0, the RestoreToolBar and SaveToolBar methods are used to manage ToolBar configuration. SaveToolBar saves the configuration to an initialization (.ini) file; RestoreToolBar returns it to its original state after being customized.
The Visual Basic 2008 ToolStrip control has no equivalent methods. You can use the Settings Designer to manage configurations for the ToolStrip control. For more information, see Managing Application Settings.
ToolBar Control Property and Method Equivalencies
The following tables list Visual Basic 6.0 properties and methods, along with their Visual Basic 2008 equivalents. Those properties and methods that have the same name and behavior are not listed. All Visual Basic 2008 enumerations map to the System.Windows.Forms namespace unless otherwise noted.
This table provides links to topics explaining behavior differences. Where there is no direct equivalent in Visual Basic 2008, links are provided to topics that present alternatives.
Properties
Visual Basic 6.0 |
Visual Basic 2008 Equivalent |
---|---|
Align |
|
AllowCustomize |
New implementation. You must provide your own dialog box. |
Appearance BorderStyle |
New implementation. For more information, see Appearance and BorderStyle Properties for Visual Basic 6.0 Users. |
ButtonHeight |
|
Buttons |
|
ButtonWidth |
|
Container |
|
Controls |
|
DataBindings |
New implementation. For more information, see Data Access for Visual Basic 6.0 Users. |
DisabledImageList |
New implementation. Use the Image property of the ToolStripButton object. |
DragIcon DragMode |
New implementation. For more information, see Drag and Drop 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.
|
HelpContextID HelpFile |
New implementation. For more information, see Help Support for Visual Basic 6.0 Users. |
HotImageList |
New implementation. Use the Image property of the ToolStripButton object. |
HWnd |
Handle |
ImageList |
New implementation. Use the Image property of the ToolStripButton object. |
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 |
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 |
|
ShowTips |
|
Style |
New implementation. Use the TextImageAlign property of the ToolStripItem. |
TextAlignment |
TextAlign (ToolStripItem) |
ToolTipText |
ToolTip component For more information, see ToolTip Support for Visual Basic 6.0 Users. |
Value |
Note:
In Visual Basic 6.0, when the Value is changed, the Change event is raised. In Visual Basic 2008, the Change event is not raised; use the ValueChanged event instead.
|
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. |
Wrappable |
Methods
Visual Basic 6.0 |
Visual Basic 2008 Equivalent |
---|---|
Customize |
New implementation. You must provide your own dialog box. |
Drag |
New implementation. For more information, see Drag and Drop 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. |
RestoreToolbar SaveToolbar |
New implementation. Use the Application Settings feature. |
ShowWhatsThis |
New implementation. For more information, see Help Support for Visual Basic 6.0 Users. |
ZOrder: |
BringToFront or SendToBack function. |
Events
Visual Basic 6.0 |
Visual Basic 2008 Equivalent |
---|---|
Change |
New implementation. The Customize ToolBox dialog box no longer exists. |
DblClick |
|
DragDrop DragOver |
New implementation. For more information, see Drag and Drop 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 project is upgraded to Visual Basic 2008, any ToolBar controls are upgraded to Windows Forms ToolStrip controls. Where properties, methods, and events have no equivalent or have differences in behavior, upgrade notes or warnings will be added to your code.
See Also
Reference
ToolStrip Control Overview (Windows Forms)