Change Toolbar dropdown menu from two buttons to one

DiverDan

Well-known member
Joined
Jan 16, 2003
Messages
645
Location
Sacramento, CA
User Rank
*Experts*
When I add a context menu to a toolbar button, two buttons are created. How can these two buttons be combined into one simular to Internet Explorers mail button?

Or

To be able to display the context menu with the toolbars button press and not use the dropdown arrow.

Thanks
 
Last edited by a moderator:
It looks like setting the DropDownMenu property of the button to the contextmenu, and also setting the Style property to DropDownButton achieves this effect.

If you simply wanted the menu to appear in the button press, in code you can use the contextmenus Show method.
 
The DropDownMenu property is set to the contextmenu and the Style property is set to DropDownButton. This produces two buttons, one with the icon that does nothing and the other with an down arrow that displays the context menu. I think it would be better to just use the contextmenu show method and leave the button as a regular button. I am still new to vb.net and would appreciate an example of showing the context menu.

Thanks
Dan
 
Something like this, maybe?

Code:
    Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
        If e.Button Is ToolBarButton1 Then ContextMenu1.Show(Me, PointToClient(Cursor.Current.Position))
    End Sub

Obviously substituting the name of your button for ToolBarButton1.
 
I actually figured it out last night after you pointed me in the right direction. Thanks a lot for your help Divil, you saved my day.

Dan
 
Back
Top