• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 652
  • Last Modified:

creating toolbar having combo in tbrplaceholder

hi all.
i am trying to create a toolbar using VB 6.0.
i wish to have a combo box in it.
please provide me the help / code for the same.
THANKS>
0
Sandeep Sood
Asked:
Sandeep Sood
  • 4
  • 3
  • 3
2 Solutions
 
anvCommented:
hi try this

1. Start a new Visual Basic project. Form1 is created by default.  
2. Place a ComboBox on the form.  
3. Place a Toolbar on the form.  
4. Add the following code to the Form1 code window:    Option Explicit

   Private Sub Form_Load()
      Dim btn As Button
      Me.Show
      Set btn = Toolbar1.Buttons.Add()
      btn.Style = tbrSeparator
      Set btn = Toolbar1.Buttons.Add()
      btn.Style = tbrPlaceholder
      btn.Key = "ComboBox"
      btn.Width = 2000

      DoEvents

      With Combo1
         .ZOrder 0
         .Width = Toolbar1.Buttons("ComboBox").Width
         .Top = Toolbar1.Buttons("ComboBox").Top
         .Left = Toolbar1.Buttons("ComboBox").Left
      End With
   End Sub


 


0
 
SCDMETACommented:
Consider using a Coolbar.

Insert the Coolbar like a normal toolbar.  The Coolbar has bands (typically three to start with.)  Each band can host another control.  For example: Band1 can hold a toolbar with buttons.  Band2 can host a combo box.  Band3 can host a picture box (which can also host other controls).

1. Create a new project (choose VB Pro Edition Controls or Add the Microsoft Windows Common Controls-3 6.0 to as standard project.)
2. Drap a cool bar onto the form.
3. Set the coolbar align to vbAlignTop
4. Drag a toolbar on to the Coolbar
5. Drag a combobox on to the Coolbar
6. Drag a Picture Box on to the Coolbar
7. Right click the Coolbar and select Properties.
8. Go to the Bands tab
9. For Index 1, (ie Band 1) set the Child Control to Toolbar1
10. For Index 2, (ie. Band 2) set the Child Control to Combo1
11. For Index 3, (ie. Band 3) set the Child Control to Picture1
12. Click Apply and then OK

You should now see all the child controls aligned to their respective bands.
You can modify the child control border properties so they blend into the coolbar better.
You can also turn of the Band Border to make the coolbar look more like a toolbar.

Notice also that you can insert more controls onto the Picture box...in case you wanted to have multple combos in one band.



0
 
Sandeep SoodProgrammerAuthor Commented:
Thanks anv  feedback !!
it is working.
but acutally the counfusion in my mind is that why is there 6th button tbrcombo i think (except tbrplaceholder and tbrseperator) and if we can create combo using  tbrplaceholder and placing a seperate combo control over it then what is the purpose of tbrcombo ?

please help.
thanks.
The Tech Guy.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
anvCommented:
hi thetechguy

i dont see any 6th button tbrcombo  here ..

please clarify ur confusion... i'm not getting ur point ..

thanx
0
 
Sandeep SoodProgrammerAuthor Commented:
Thanks anv feedback !!

OOPS. sorry, i made a mistake.
actually sixth button style is tbrdropdown.

so if we can create a combo using place holder button style and a combo box control then what is the purpose of tbrdropdown. please explain and provide me an example / sample.
thanks.
0
 
SCDMETACommented:
This project shows an example of using tbrDropdown.  (It is a drop down menu.)

1. Start a new Visual Basic project. Form1 is created by default.  
2. Place a Toolbar on the form.  
3. Add the following code to the Form1 code window:    

Option Explicit

Private Sub Form_Load()
   Dim btn As Button
   Me.Show
   Set btn = Toolbar1.Buttons.Add()
   btn.Style = tbrDropdown
   btn.Caption = "A Menu"
   btn.Key = "MAINMENU"
   btn.ButtonMenus.Add 1, "MENU1", "First Menu Item"
   btn.ButtonMenus.Add 2, "MENU2", "Second Menu Item"
   btn.ButtonMenus.Add 3, "MENU3", "Third Menu Item"
End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    Select Case Button.Key
        Case "MAINMENU"
            MsgBox "You clicked the Main button."
    End Select
End Sub

Private Sub Toolbar1_ButtonMenuClick(ByVal ButtonMenu As MSComctlLib.ButtonMenu)
    Select Case ButtonMenu.Key
        Case "MENU1"
            MsgBox "You clicked First Menu Item"
        Case "MENU2"
            MsgBox "You clicked Second Menu Item"
        Case "MENU3"
            MsgBox "You clicked Third Menu Item"
    End Select
End Sub
0
 
Sandeep SoodProgrammerAuthor Commented:
Thanks SCDMETA  feedback !!
you helped a lot. i will give you the points.
But, please, just one more thing.
what is the need of haveing menus on tool bar when we have seperate menus on menubar.
and can you please provide me an example where this has been used i mean in MS-WORD or EXCEL or IE etc. any s/w having menus on toolbar ??
thanks again.
0
 
anvCommented:
hi thetechguy

Menus in toolbar are very often used..

Hae u USed Mail Merge Feature in MS Word....

Try using It..

u'll see a Mail Merge Toolbar..

Where The "Insert Merge Field" and "Inser Word Field" are Menus available in that toolbar

Hope U Get the Example Right..
0
 
Sandeep SoodProgrammerAuthor Commented:
Thanks anv  feedback !!
i got it now.

since both anv feedback and SCDMETA feedback
have helped a lot, i wish to give equal points to both.

thanks a lot to both.
Thanks to Experts-Exchange !!
0
 
SCDMETACommented:
If there is anything I can do to make this fair...let me know.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 4
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now