Questions tagged «contextmenustrip»

4
确定使用了ContextMenuStrip的控件
我有一个ContextMenuStrip分配给几个不同的列表框。我试图弄清楚ContextMenuStrip什么时候单击了什么ListBox。我尝试从下面的代码开始,但无法正常工作。在sender有正确的价值,但是当我尝试它分配到menuSubmitted它为空。 private void MenuViewDetails_Click(object sender, EventArgs e) { ContextMenu menuSubmitted = sender as ContextMenu; if (menuSubmitted != null) { Control sourceControl = menuSubmitted.SourceControl; } } 任何帮助都会很棒。谢谢。 使用以下帮助,我弄清楚了: private void MenuViewDetails_Click(object sender, EventArgs e) { ToolStripMenuItem menuItem = sender as ToolStripMenuItem; if (menuItem != null) { ContextMenuStrip calendarMenu = menuItem.Owner as …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.