Skip navigation

Disabling clipboard related operations in multiline text box in a windows forms application

A question often seen in the newsgroups is how one should disable the standard clipboard operations such as Cut/Copy/Paste from a multiline edit box in a windows forms control. One of the solutions that can be used to prevent the standard clipboard operations is
(as discussed in http://www.syncfusion.com/FAQ/WinForms/FAQ_c94c.asp#q961q) by:

 
(1) Disabling the default context menu (which contains the Cut/Copy/Paste menu items) from showing up.
Simply associating an empty ContextMenu with the textbox's ContextMenu property will prevent the default
ContextMenu from showing up.
 
(2) Override the ProcessCmdKey method in the derived TextBox class to indicate that any shortcut
command keys associated with the clipboard operations have already been processed.
 
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish