Posts Tagged ‘clipboard’

Copy-Paste to and from clipboard using c#

To make the operations such as copy paste using c#,we have to use the Clipboard Class which provides methods to place data on and retrieve data from the system Clipboard.

Example :-

Copy the text from txtCopy to clipboard

 System.Windows.Forms.Clipboard.SetDataObject(txtCopy.Text, true);

Paste the text from clipboard to txtPaste

IDataObject clipData = Clipboard.GetDataObject();
if (clipData.GetDataPresent(DataFormats.Text))
{
txtPaste.Text = clipData.GetData(DataFormats.Text).ToString();
}
else
{
txtPaste.Text = "Could not retrieve data from the clipboard.";
}

Download

Popularity: 41% [?]

Designed by: Business Web Hosting | Thanks to Buy Icons, travel tips and Used Cars