开发者

get contextmenustrip from toolstripmenuitem

开发者 https://www.devze.com 2023-03-12 02:54 出处:网络
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.?

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, ....

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号