How to remove the default context menu of a TextBox Control? C#

后端 未结 3 600
感动是毒
感动是毒 2021-02-04 08:36

How to remove the default context menu of a TextBox Control?

\"alt

Is there a propert

相关标签:
3条回答
  • 2021-02-04 08:55

    You can also set the ShortcutsEnabled property to 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.

    0 讨论(0)
  • 2021-02-04 09:05

    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;
        }
    }
    
    0 讨论(0)
  • 2021-02-04 09:11

    Try setting the ContextMenu property of the TextBox to a dummy, empty ContextMenu instance.

    0 讨论(0)
提交回复
热议问题