Reputation:
How to disable the right-click context menu on textboxes in Windows, using C#? Here's what I've got, but it has some errors.
private void textBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
textBox1.ContextMenu.Dispose();
}
}
Upvotes: 14
Views: 16971
Reputation: 63065
try with
textBox1.ShortcutsEnabled =false;
Use the
ShortcutsEnabled
property to enable or disable the following shortcut key combinations and the control’s shortcut menu:
CTRL+Z
CTRL+E
CTRL+C
CTRL+Y
CTRL+X
CTRL+BACKSPACE
CTRL+V
CTRL+DELETE
CTRL+A
SHIFT+DELETE
CTRL+L
SHIFT+INSERT
CTRL+R
Upvotes: 16