Do I use 开发者_如何学Gothe Owner
, OwnerItem
, or the Container
property?
What if the ToolStripMenuItem
is a member of another tsmi, which in turn is a member of another tsmi, etc.?
The purpose of this is to be able to add an event handler that gets at the TreeView
that has the ContextMenuStrip
that has that ToolStripMenuItem
.
Abstracting a bit, is there a general way to get at the owners of controls, until you reach the one you're interested in? Just cast and hope?
use ToolStripMenuItem1.GetCurrentParent()
for getting parent of controls which inherited from System.Windows.Forms.Control read Parent
like Button1.Parent, ....
精彩评论