This is not as easy as it should be. CoolBar controls contain Band objects that represent the groupings of things in the CoolBar. Right-click the CoolBar and select Properties to manage the Bands. Each Band can hold only one child control. You will probably want that child to be some other container control so it can hold more than one thing itself.
Start by creating the CoolBar at design time. Create its child inside the CoolBar. Do this just as you would place a control inside any other container such as a Frame or PictureBox.
You can right click on the CoolBar and select the child into a Band at design time, or you can set a Band's Child property at run time.
In this example, two Toolbars were placed in the CoolBar at design time. The Form_Load event handler attaches ImageLists to the Toolbars and makes buttons in them. The program then adds the Toolbars to the CoolBar's Bands.
|
Private Sub Form_Load()
Dim btn As Button
Dim band1 As Band
' Prepare the toolbars.
Set Toolbar1.ImageList = ImageList1
Toolbar1.Buttons.Add , "Happy", , tbrDefault, 1
Toolbar1.Buttons.Add , "Grouchy", , tbrDefault, 2
Toolbar1.Buttons.Add , "Sad", , tbrDefault, 3
Set Toolbar2.ImageList = ImageList2
Toolbar2.Buttons.Add , "X", , tbrDefault, 1
Toolbar2.Buttons.Add , "O", , tbrDefault, 2
' Prepare the coolbar.
CoolBar1.Align = vbAlignTop
CoolBar1.Bands.Clear
CoolBar1.Bands.Add , , , , , Toolbar1
CoolBar1.Bands.Add , , , , , Toolbar2
CoolBar1.Bands(1).Width = CoolBar1.Width / 2
CoolBar1.Bands(2).Width = CoolBar1.Width / 2
End Sub
|