Click to See Complete Forum and Search --> : adding string to clipboard


dky1e
October 7th, 2002, 03:04 PM
Hi,

How can i add the contents of a string to windows clipboard?

Thanks.

dky1e
October 7th, 2002, 03:09 PM
nevermind... it's easy There is a Clipboard clas in Windows.Forms.

from c-sharpcorner.com:

private void CutCopyData()
{
Clipboard.SetDataObject(textBox1.SelectedText);
}

private void PasteData()
{
IDataObject iData = Clipboard.GetDataObject();
//Determine whether the data is in a format you can use.
if(iData.GetDataPresent(DataFormats.Text))
{
string str = (String)iData.GetData(DataFormats.Text);
}
}