c#如何从至少两个级别的基础子菜单中转到上下文menustrip
如何从其基础子菜单中转到ContextMenustrip,它是工具stripdropdownmenu的工具速率,它是该contextMenustrip的toolstripmenuitem的下拉?
问题在于工具条流式曼努犬类,在该类中找不到属性,请参阅上级对象,例如其cassived toolstripmenuitem.its parent,容器属性和getContainerControl()方法all return null。
我的目的是在单击任何基础菜单项时都知道ContextMenustrip的SourceControl。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
onalyItem
属性获取toolstripitem
:You can use
OwnerItem
property to get theToolStripItem
:您需要向后循环才能获得第一个
asloreTem
给定toolsstripitem
的属性(或 sunived ofer noreflow noreferrer“> suret oferived 类)toolstrip
(可以是toolstrip
,menustrip
,statusstrip
,或condect> contextmenustrip
控制)通过toolstripitem.outher
属性。考虑以下扩展方法:
以下是一个示例,该示例显示了如何获得
itemClicked 事件:事件:
contextMenustrip.sourcecontrol
在You need a backward loop to get the first
OwnerItem
property of a givenToolStripItem
(or one of the derived classes) in a branch then you can get the mainToolStrip
(which can be aToolStrip
,MenuStrip
,StatusStrip
, orContextMenuStrip
control) through theToolStripItem.Owner
property.Consider the following extension methods:
Here's an example that shows how to get the
ContextMenuStrip.SourceControl
in theItemClicked
event: