toolbarbutton and dropdown style

A

Ahmed

Hi everyone,

Is there a way to add a toolbarbutton with dropdown menu similar to the
mail button in IE? In another word, when the chevron is part of the
button not beside it.


Thanks

Ahmed
 
B

Bernie Yaeger

Hi Ahmed,

I have something in a toolbar that pretty much replicates what you're after.
Here's the basic code. The key element is the style of tbopenbutton3, which
is set to 'dropdownmenu' and then assigned a context menu. Instead of
activating from clicking the button's image, it is activated by selecting
the dropdown arrow and then clicking on the selection.
If you have trouble with the code, let me know; I'll be glad to help.

--------------------------

Dim toolbaricons As ImageList = New ImageList

Dim tbopenbutton As ToolBarButton = New ToolBarButton

Dim tbopenbutton2 As ToolBarButton = New ToolBarButton

tbopenbutton.ImageIndex = 0

tbopenbutton.ToolTipText = "View and print standard reports"

tbopenbutton.Text = "| Standard Reports |"

tbopenbutton2.ImageIndex = 1

tbopenbutton2.ToolTipText = "General Help"

tbopenbutton2.Text = "| IMC System Help |"



ToolBar1.Appearance = ToolBarAppearance.Normal

ToolBar1.Buttons.Add(tbopenbutton)

ToolBar1.Buttons.Add(tbopenbutton2)

ToolBar1.ImageList = toolbaricons

toolbaricons.ImageSize = New System.Drawing.Size(32, 32) ' this could be any
size

toolbaricons.Images.Add(New Icon("f:\imcapps\printer1.ico"))

toolbaricons.Images.Add(New Icon("f:\imcapps\magglass1.ico"))

toolbaricons.Images.Add(New Icon("f:\imcapps\imclogo3.ico"))

Dim tbopenbutton3 As ToolBarButton = New ToolBarButton

tbopenbutton3.ImageIndex = 2

tbopenbutton3.ToolTipText = "Reference Tables"

tbopenbutton3.Text = "| References |"

ToolBar1.Buttons.Add(tbopenbutton3)

tbopenbutton3.Style = ToolBarButtonStyle.DropDownButton

tbopenbutton3.DropDownMenu = ContextMenu1

HTH,

Bernie Yaeger
 
A

Ahmed

Hi Bernie,

You code basically creates not a true drop down button. it creates a a
button and an arrow beside it. we have two entities in this case. What
I want to do is to have one button with the arrow on the button itself
not next to it. So, when clicking on the item a context menu appears.
Your example creates a button similar to the "back" and "forward"
button in internet explorer. I want something like the "mail" button in
internet explorer.

Thanks for the help though

Ahmed
 
B

Bernie Yaeger

Hi Ahmed,

I see what you mean.

The mail button in ie appears to be almost its own little main menu, if
that's possible, and the envelope icon and the down arrow are really just
one .ico file, I believe.

I will let you know if I come up with something; I'll play around with a few
ideas.

Bernie
 
A

Ahmed

Thanks man.
I tried attaching a context menu to a push button but it does not
work. the button needs to be a dropdownbutton to have the context menu
working.
 

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

Top