简体   繁体   English

如何删除文本框控件的默认上下文菜单? C#

[英]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.

相关问题 如何在Windows 10 UWP应用程序中删除TextBox控件的默认“粘贴”上下文菜单项? - How can I remove the default “Paste” context menu entry of a TextBox control in a Windows 10 UWP app? 上下文菜单和将项目添加到文本框C# - Context Menu and Adding items to textbox c# 如何使用父控件的上下文菜单覆盖文本框上下文菜单? - How to override textbox context menu with parent control's context menu? ListView控件中的TextBox在当前上下文中不存在 C# - TextBox within ListView control does not exist in current context | C# 如何更改(以及稍后恢复)文本框中的默认上下文菜单 - How to change( and later restore) default context menu in textbox 如何通过文本框(C#)控制轨迹栏 - How to control a trackbar by textbox (C#) C#-如何在文本框上管理CONTROL +数字? - c# - how to manage CONTROL + digit on a TextBox? 如何在C#中获取文本框控件 - How to get Textbox control in C# 如何在UserControl资源+ Infragistics控件(WPF),C#中访问上下文菜单 - How to access context menu in UserControl Resources + Infragistics Control(WPF), C# 如何在c#WebBrowser控件中捕获上下文菜单“查看源代码”? - How to capture context menu “view source” click in c# WebBrowser control?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM