VB.net(桌面)上下文菜单分配给多个控件所有者问题
我在同一窗体上有两个不同的网格控件。 它们共享相同的上下文菜单。 当我选择上下文菜单项时,我无法确定哪个控件是所有者。
I have two different grid controls on the same form. They share the same context menu. I am having trouble determining which control is the owner when I select the context menu item.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ContextMenuStrip 类上的 SourceControl 属性将显示导致该菜单条显示的最后一个控件。
SourceControl property on the ContextMenuStrip class will show the last control that caused that menu strip to be shown.
MenuItem 的 Click 事件的事件处理程序将有一个 Sender 参数。 该对象应该是显示上下文菜单时获得焦点的控件。
The event handler for the MenuItem's Click event will have a Sender parameter. This object should be the control that had the focus when the context menu was displayed.