BUG: Controls Cannot Be Added to Toolbar ProgrammaticallyID: Q172343
|
With Visual Basic, you may add controls to a Toolbar control by creating a placeholder button on the toolbar and then setting the control to the same position. If you use the Comctl32.ocx that ships with Visual Studio 97 and Visual Basic 5.0, or MSCOMCTL.OCX that ships with Visual Studio 6.0 and Visual Basic 6.0, the control may unexpectedly appear behind the toolbar.
To work around this problem, create a pause with DoEvents after you set all
the controls in place and then set the Toolbar control to the bottom of the
ZOrder.
NOTE: This workaround does not apply to non-windowed controls, such as a
Label or a Shape. To use this workaround with non-windows controls,
the controls must be contained in a PictureBox.
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
Private Sub Form_load()
Dim btn As Variant
Me.Show
'Add a separator to the toolbar
Toolbar1.Buttons.Add Style:=tbrSeparator
'Add a Placeholder to the toolbar.
Set btn = Toolbar1.Buttons.Add(Key:="ComboBox", _
Style:=tbrPlaceholder)
btn.Width = 2000
'Place the combo box on top of the Placeholder
With Combo1
.Width = btn.Width
.Top = btn.Top
.Left = btn.Left
.ZOrder 0
End With
End Sub
DoEvents
Toolbar1.ZOrder 1
Additional query words:
kbVBp400bug kbVBp500bug kbVBp600bug kbVBp kbDSupport kbdsd kbInetDev100bug
kbControl
Keywords :
Version :
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: June 17, 1999