Previous | Index | Next 

[INFO] The .NET Toolbar control can’t contain standard controls

The VB6 Toolbar control is capable to contain regular control, such as TextBox and ComboBox control; this capability is missing in the .NET ToolStrip control and is therefore missing in VB Migration Partner’s VB6Toolbar control, which is just a wrapper for the ToolStrip control. (The .NET Toolbar control can only contain controls that inherit from the System.Windows.Forms.ToolStripItem base class, e.g. ToolStripButton or ToolStripComboBox controls.)

VB Migration Partner recognizes that the Toolbar can’t work as a container in VB.NET and correctly moves the toolbar’s child controls to the form’s surface, so that they appear in front of the toolbar itself. These actions make the converted VB.NET form look very similar to the original VB6 form.

However, if the form contains two or more toolbars, typically the controls that used to be contained in the VB6 toolbar are misplaced on the VB.NET form and overlap a different toolbar control, possibly hiding other controls. If this is the case, you must set the position of these child controls manually, from inside the Form_Load event handler.

For example, suppose that you are converting a form that has three toolbars on it. Toolbar1 is the top-most toolbar; Toolbar2 is located below Toolbar1 and contains a child control named Combo1; Toolbar3 is located below Toolbar2 and contains a child control named Text1. The best way to ensure that the positions of the two child controls are migrated correctly is adding a bunch of InsertStatement pragmas in the original VB6 code:

        Private Sub Form_Load()
             '##InsertStatement Combo1.Move(Combo1.Left + Toolbar2.Left, _
                 Combo1.Top + Toolbar2.Top)
             '##InsertStatement Text1.Move(Text1.Left + Toolbar3.Left, _
                 text1.Top + Toolbar3.Top)
             ' original code for the Form_Load event here ...
         End Sub

Needless to say, this should be regarded as a temporary solution. After converting the application to VB.NET you should replace child controls with equivalent controls that inherit from the ToolStripItem class. For example, the Combo1 control should be replaced by a ToolStripComboBox control and the Text1 control should be replaced by a ToolStripTextBox control. After such replacements, the code in the Form_Load event should be deleted.

 

Previous | Index | Next