Adding a Combobox to a Toolbar

  • Thread starter Thread starter Juan Pedro Gonzalez
  • Start date Start date
J

Juan Pedro Gonzalez

I wanted to add a Combobox to a toolbar... Kind of the look you get on
VisualStudio's toolbar.

I've been able to find some VB 6 samples, but the placeholder option is no
longer available for ToolbarButtons...

Does anyone know how this could be done?

Looking forward to hear from you,

Juan
 
Not sure if this is what you are looking for but, you can add a combobox to
a toolbar by dragging and dropping it onto a toolbar on your form.

You might find it better to create a menu, then add a button to the toolbar
that references that menu and has a style of dropdown.

These are all properties found in the toolbar buttons collection.
 
Helo,

When I drag and drop a ComboBox over the Toolbar, Visual Studio seems to add
the combo to the main form not the toolbar. After this I tried adding the
combo manually to the toolbar controls collection. This works fine, but some
times it messes up and the Form Designer won't show any controls at all.
When this happens if I modify anything on the Form designer, my entire form
gets whipped out and I find that my controls have dissapeared.

To solve this issue I created a new control inherited from the Toolbar and I
add here the ComboBox... The only problem here is that the ComboBox will
only show one item and the scroll. I need more items shown on the list.
Don't really know how to solve this issue at the moment. Help would be
appreciated.

Another problem is that the window must be fixed, since it won't resize
correctly the toolbar to fit the ComboBox... This issue isn't much of a
problem since I need it for a fixed (Not resizable) window.

The DropDown Button was another option I was considering, but I can't get a
fixed width for it, therefore it gives a strange felling when changing
items.
 
All true. Sorry I didn't mention those issues.

Mark has also made some good suggestions as well in this thread.

I'm thought there was another way as well but it escapes me at the moment.
I'll have to dig a little further.
 
Juan,

The answer is very simple, the draging of the toolbar acts strange. It has a
kind of effect what has to do with the Z (bottom up) order of placing
controls what is forever strange with controls where is the dock (as is
standard with the toolbar) set.

When you first set a control on a form
Than the toolbar and than drag the control over the toolbar you have a
problem.

When you first drag your toolbar on a form and than the control over it, it
goes fine.
\
\\This shows the combobox in the first way 'strange behaviour of the
designer
Me.Controls.Add(Me.ComboBox1)
Me.Controls.Add(Me.ToolBar1)
///
\\\This shows the combobobox not it is in the second way 'same strange
behaviour
Me.Controls.Add(Me.ToolBar1)
Me.Controls.Add(Me.ComboBox1)
///
\\\This shows as well and when done will be corrected in the desinger to set
it in the toolbar
Me.Controls.Add(Me.ToolBar1)
Me.ToolBar1.Controls.Add(Me.ComboBox1)
///

It is strange

I hope this helps?

Cor
 
Juan,

doh.
\ \\This shows the combobox, it is the second way 'strange behaviour of the
designer
Me.Controls.Add(Me.ComboBox1)
Me.Controls.Add(Me.ToolBar1)
///
\\\This shows the combobobox not, it is in the first way
Me.Controls.Add(Me.ToolBar1)
Me.Controls.Add(Me.ComboBox1)
///

Sorry I made it a little bit confusing.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top