1

我使用Owner, OwnerItem, 还是Container属性?

如果ToolStripMenuItem是另一个 tsmi 的成员,而后者又是另一个 tsmi 的成员,等等怎么办?

这样做的目的是能够添加一个事件处理程序,该处理程序可以获取TreeViewthat has the ContextMenuStripthat has that ToolStripMenuItem

稍微抽象一下,有没有一种通用的方法可以找到控件的所有者,直到找到您感兴趣的那个?只是投射和希望?

4

1 回答 1

4

use ToolStripMenuItem1.GetCurrentParent()

for getting parent of controls which inherited from System.Windows.Forms.Control read Parent

like Button1.Parent, ....

于 2011-06-12T16:24:17.643 回答