[英]How to remove the default context menu of a TextBox Control? C#
How to remove the default context menu of a TextBox
Control? 如何删除
TextBox
控件的默认上下文菜单?
Is there a property to disable it? 有禁用它的属性吗?
Thanks :) 谢谢 :)
You can also set the ShortcutsEnabled
property to false
. 您还可以将
ShortcutsEnabled
属性设置为false
。 This removes the default context menu and all clipboard functionality. 这将删除默认的上下文菜单和所有剪贴板功能。 I presume that's why you're trying to suppress the menu?
我想这就是为什么您要取消显示菜单的原因? I can't think of any good reason other than purposefully preventing your users from using copy/paste.
除了有意阻止用户使用复制/粘贴功能外,我没有其他任何理由。
尝试将TextBox的ContextMenu属性设置为虚拟的空ContextMenu实例。
This works: 这有效:
public partial class Form1 : Form
{
ContextMenu blah = new ContextMenu();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.ContextMenu = blah;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.