Free Web Site - Free Web Space and Site Hosting - Web Hosting - Internet Store and Ecommerce Solution Provider - High Speed Internet
Search the Web

Add a CombBox control into ToolBar

VB Tips:  ToolBar


   Preparations:

   1. Add a Toobar control into a form
   2. Drag a ComboBox control into the Toolbar
   3. Add a Toolbar button named 't1 with a checked property of tbrPlaceHolder. The ComboBox will put on it later.
       Another way, you can add below codes to add such toolbar button in run time:

Toolbar1.Buttons.Add(, "t1", , tbrPlaceholder)

 

   Codes:

Private Sub load()
   Toolbar1.Buttons("t1").Width = 1500
   Show     'in order to continue setup properties of ComboBox
   With Combo1
      .Width = Toolbar1.Buttons("t1").Width
      .Top = Toolbar1.Buttons("t1").Top
      .Left = Toolbar1.Buttons("t1").Left
      .AddItem "Black"
      .AddItem "Blue"
      .AddItem "Red"
      .ListIndex = 0
   End With
End Sub

Private Sub Form_Resize()
   With Combo1
      .Width = Toolbar1.Buttons("combo1").Width
      .Top = Toolbar1.Buttons("combo1").Top
      .Left = Toolbar1.Buttons("combo1").Left
   End With
End Sub

Private Sub Combo1_Click()
   'Choose the back color of the form
   Select Case Combo1.ListIndex
   Case 0
      Form1.BackColor = vbBlack
   Case 1
      Form1.BackColor = vbBlue
   Case 2
      Form1.BackColor = vbRed
   End Select
End Sub

 


Copyright (c) 1999 - 2001, robert han, all rigths are reserved.