Winforms中的上下文菜单 [英] Context menu in winforms
本文介绍了Winforms中的上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Winforms中创建和关闭上下文菜单?
How to create and close the Context Menu in Winforms?
推荐答案
看看以下内容:
MSDN:向Windows窗体添加上下文菜单 [ ^ ]
将上下文菜单添加到表单窗口 [
Have a look at these:
MSDN: Adding Context Menus to Windows Forms[^]
Add context menu to a form window[^]
Try now!
在图片"框中使用以下代码显示上下文"菜单.它将在右键单击PictureBox上显示默认的上下文菜单:
Use Following code on Picture box to display Context menu. It will display default context menu on Right clicking the PictureBox:
private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
{
Point p = new Point(900, 5);
if (e.Button == MouseButtons.Right)
{
ContextMenuStrip cms = new ContextMenuStrip();
pictureBox1.PointToClient(p);
cms.Show(comboBox1, p.X, p.Y);
}
}
这篇关于Winforms中的上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文