有个简单的方法,那就是在页面上拖个contextMenuStrip,什么也不设置
把要禁用右键的控件的ContextMenuStrip属性设为this.contextMenuStrip控件就行了
例this.pictureBottom.ContextMenuStrip = this.contextMenuStrip1;
如果禁用右键的控件单击事件中是触发的CLOSE(),程序会异常,自己调试看看,可能就会用到
下面的方法知道就行了,
由于水平有限,并没有真正禁用右键,而是对使用右键做了相关的提示处理
//当按下鼠标按钮
void pbx_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{//如果判断是右键点的, string m = "鼠标右键己被禁用";
System.Windows.Forms.MessageBox.Show(
m, "提示信息", System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Information); }
}
{
if (e.Button == MouseButtons.Right)
{//如果判断是右键点的, string m = "鼠标右键己被禁用";
System.Windows.Forms.MessageBox.Show(
m, "提示信息", System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Information); }
}
出一个提示信息
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23109131/viewspace-631044/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/23109131/viewspace-631044/