VB.net (desktop) context menu assigned to multiple controls owner problem

给你一囗甜甜゛ 提交于 2020-01-15 04:16:59

问题


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.


回答1:


SourceControl property on the ContextMenuStrip class will show the last control that caused that menu strip to be shown.




回答2:


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.



来源:https://stackoverflow.com/questions/244002/vb-net-desktop-context-menu-assigned-to-multiple-controls-owner-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!