If you use CTRL+C, some data or files are copied to the system clipboard memory and when you use CTRL+V, the data is copied back to wherever you paste it. The Clipboard class provides functionality to place data to and retrieve data from the clipboard.
Storing and Retrieving Data
Clipboard has static methods to copy and paste data. The SetDataObject method is used to store data that is in object format to the clipboard. The following code snippet copies selected text from a RichTextBoc control to the clipboard.
- Clipboard.SetDataObject(richTextBox1.SelectedText);
The GetDataObject method reads data back from the clipboard. The following code snippet gets data from the clipboard and displays in a Label control.
- // Retrieves data
- IDataObject iData = Clipboard.GetDataObject();
- // Is Data Text?
- if (iData.GetDataPresent(DataFormats.Text))
- label1.Text = (String)iData.GetData(DataFormats.Text);
- else
- label1.Text = "Data not found.";
- Clear Clipboard
- Clear method removes all data from the Clipboard.
- Clipboard.Clear();
Summary
The Clipboard class provides methods to save to and retrieve data from system clipboard.

Lucy LuebbersPosted Oct 25, 2022, 2:33 AM EDT
Now imagine I wouldnt need to go to another article that states the same AND includes the library this is in
Taha TemuriPosted Aug 23, 2019, 12:15 AM EDT
Such a kiddie code.
Israel ValdezPosted Aug 22, 2019, 2:21 PM EDT
Excuse me, I tried to convert your code above to vb.net, I have a question, what class you use??? for imports....Thank you in advanced. I trying to get value from clipboard using ASP.Net with VB.NEt
Sonu ChaudharyPosted Apr 6, 2016, 8:55 AM EDT
thanks for article
ahasan nahidPosted Sep 15, 2014, 12:34 AM EDT
Nice Idea but i want to how excel row select manual copy but Automatic past my form input box, Its Possible!!! please help me.
subodhan purvantPosted Jul 3, 2014, 4:21 AM EDT
I have using a small console application .In application I export Datatable in Excel with the help of copy to clipboard method but whenever another user enter ctrl + c or ctrl + v therfore occur error...any suggestion
subodhan purvantPosted Jul 3, 2014, 4:20 AM EDT
Hello
subodhan purvantPosted Jul 3, 2014, 4:18 AM EDT
hi
janani muthaiyanPosted Mar 19, 2013, 10:42 PM EDT
I tried the same using ASP it shows error related to STA mode.. How can i solve this?
Biswarup GhoshPosted Jul 10, 2012, 11:14 PM EDT
My two text boxs. 1.textBox1.Text 2.textBox2.Text I want to copy string from textBox1 to textBox2 -------------------Simple code------------------------- if (textBox1.Text != null && textBox1.Text != "") { Clipboard.SetText(textBox1.Text); } IDataObject iData = Clipboard.GetDataObject(); if (iData.GetDataPresent(DataFormats.Text)) textBox2.Text = (String)iData.GetData(DataFormats.Text);
Kunal VaishyaPosted Jun 6, 2012, 2:59 AM EDT
thanks dear it help full
Kunal VaishyaPosted Jun 6, 2012, 2:59 AM EDT
thanks dear it help full
Kunal VaishyaPosted Jun 6, 2012, 2:59 AM EDT
thanks dear it help full
DMR SantoshPosted Mar 1, 2011, 2:03 AM EST
Hi Mahesh, I developed a small window application where it takes an image and name in textbox and i need to take both image and textbox value in a fresh window with the image and label on it ( i.e textbox content) and i need to save as an image file (either jpg or png).
sivakumarmrPosted Nov 3, 2010, 11:38 PM EDT
sd fsdfdfssd sd fsdfsdf
MagPosted Aug 2, 2010, 3:18 AM EDT
Hi Mahesh.. How can we retrieve Clip board values in Web application. I actually want to retrieve the copied cells of a excel and need to make a insert in my application. Is that possible?
vamsi krishnaPosted Jun 24, 2010, 5:59 AM EDT
I am using the method IDataObject iData = Clipboard.GetDataObject(); in my web application (vs 2008 & windows 2003) but it is always returning a null value whenever i try to copy the excel data and use here. So can you please suggest me what changes do i need to be made in order to get this feature working at my end. thanks, vamsi.
sam youngPosted Dec 12, 2009, 10:21 PM EST
I have a question I hope you can help, I'm a beginner at this point. Thanks. Question: I have a picture box which the user draws on. Just like in paint, I want to have the user select a copy button, and then they can outline a box of an area of the picture box they want to copy to the clipboard. Can you offer any tips on how to do this?
Prabodh MinzPosted May 27, 2009, 9:15 PM EDT
Any class that derives from DependencyObject cannot be obtained back from the clipboard.. I have a class (derives from DependencyObject) that need to be copied as a new instance...one way was to serialize it and get back by deserializing it...but its not possible because of the same reason...any idea how to achieve it... Error: WindowBase is not marked as serializable