Copy text from TextBox

A

Angel J. Hernández M.

You can use the Clipboard class. For example:

Copying
******
Clipboard.SetDataObject(MyTextbox.SelectedText, true);

Cutting
******
Clipboard.SetDataObject(MyTextbox.SelectedText, true);
MyTextbox.Text = string.Empty;

Pasting
******
IDataObject data = Clipboard.GetDataObject();

if (data.GetDataPresent(DataFormats.Text))
MyTextBox.Text = (string) data.GetData(DataFormats.Text);

Regards,
 
A

Alan Pretre

David Dvali said:
How can I cut/copy/paste text from/into textbox using clipboard from my
code?

The textbox control has Copy(), Cut(), and Paste() methods.

-- Alan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top