Dim A New ToolStripDropDownItem And Add It To A ToolStripDropDownButton

Feb 5, 2012

I also want to make the ToolStripDropDownItem "checkable", if you know what i mean...

View 3 Replies


ADVERTISEMENT

.net - Getting The Highest Owner Of A ToolStripDropDownItem?

Jun 11, 2010

I'm currently working on a project in which at one point, the user may right click a button which brings up a contextMenuStrip. I am already able to find the owner accurately from that strip, and manipulate the button clicked as follows:

Dim myItem As ToolStripMenuItem = CType(sender, ToolStripMenuItem)
Dim cms As ContextMenuStrip = CType(myItem.Owner, ContextMenuStrip)
Dim buttonPressed As DataButton = DirectCast(cms.SourceControl, DataButton)

But now for the tricky part. Within this contextmenuStrip, I have a DropDown menu with multiple items in there. I would assume you would be able to work your way up the ladder doing casts like above in the manner of

ToolStripDrowpDownItem > ToolStripDropDownMenu > ToolStripMenuItem > ContextMenuStrip

Unfortunately, when I try to get the sourcecontrol from this menuStrip, it return Nothing. Any ideas on how I can get the button that was pressed from this toolStripMenuItem? My current code is as follows (in which the sourceControl is Nothing)

Dim myItem As ToolStripDropDownItem = CType(sender, ToolStripDropDownItem)
Dim dropDown As ToolStripDropDownMenu = CType(myItem.Owner, ToolStripDropDownMenu)
Dim menuItem As ToolStripMenuItem = CType(dropDown.OwnerItem, ToolStripMenuItem)
Dim cms As ContextMenuStrip = CType(menuItem.Owner, ContextMenuStrip)
Dim buttonPressed As DataButton = DirectCast(cms.SourceControl, DataButton)

how to go about doing what I did in that first method, but just working my way up from further down the ladder?

View 1 Replies

VS 2005 Same ToolStripItems For ToolStripDropDownButton And ContextMenuStrip?

Sep 4, 2009

At design-time I have added the ToolStripItems to the ToolStripDropDownButton but I want to provide a Context Menu which has the same items but when I am adding the items to the ContextMenuStrip at runtime they are removed from the ToolStripDropDownButton and are only available to the ContextMenuStrip already, is it not possible to have them in both ToolStripDropDownButton and ContextMenuStrip?Rather than duplicating the menus I would have preferred utilizing them in both ToolStripDropDownButton and ContextMenuStrip.

View 2 Replies

ToolStripDropDownButton Click Event For Child Buttons?

Dec 21, 2009

I have a application with a toolstrip. I placed a toolstripdropdownbutton on it that is called 'Favorites'.

I add buttons to it programatically during runtime. But how do I add a click event to them? Or does the toolstripdropdownbutton has a click event for his children?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved