Change Toolbar dropdown menu from two buttons to one

DiverDan

Contributor
Joined
Jan 16, 2003
Messages
645
Location
Sacramento, CA
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 Explorer's mail button?

Or

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

Thanks
 
Last edited:
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 contextmenu's 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?

Visual Basic:
    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.
 
Back
Top