Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I allow CTRL-V (Paste) on a Winforms Textbox?

Tags:

c#

.net

winforms

I have several textboxes on a windows form.

I can't paste text into any of them using CTRL-V, though I can still right click and select paste. This is pretty annoying.

I have tried this with the form's KeyPreview as both true and false. TextBox.ShortcutsEnabled is also true.

like image 612
Neil N Avatar asked Dec 09 '09 20:12

Neil N


People also ask

How do I enable paste in TextBox?

Make sure that yourTextBox. ShortcutsEnabled is set to true . Note that if ShortcutsEnabled is false this also suppresses the standard context menu of the TextBox control, which would prevent pasting using the mouse.

Do not allow Paste in TextBox c#?

In WinForms, the easiest way to disable cut, copy and paste features on a textbox is to set the ShortcutsEnabled property to false.

How to disable copy Paste in TextBox in Vb net?

Set ShortcutsEnabled property to False . This will disable Cut, Copy and Paste.

What is TextBox control in C#?

This property is used to set a value which shows whether pressing ENTER in a multiline TextBox control creates a new line of text in the control or activates the default button for the given form.


2 Answers

Check to see if you have a menu on the form with a shortcut for Ctrl-V.

like image 171
Jeremy McGee Avatar answered Sep 19 '22 08:09

Jeremy McGee


The following code should help:

private void textBox1_KeyUp(object sender, KeyEventArgs e) {
  if (e.KeyData == Keys.V && e.Modifiers == Keys.Control)
    (sender as Textbox).Paste();
}
like image 27
Webleeuw Avatar answered Sep 22 '22 08:09

Webleeuw