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, 6:33 AM
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, 4:15 AM
Such a kiddie code.
Israel ValdezPosted Aug 22, 2019, 6:21 PM
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, 12:55 PM
thanks for article
ahasan nahidPosted Sep 15, 2014, 4:34 AM
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, 8:21 AM
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, 8:20 AM
Hello
subodhan purvantPosted Jul 3, 2014, 8:18 AM
hi
janani muthaiyanPosted Mar 20, 2013, 2:42 AM
I tried the same using ASP it shows error related to STA mode.. How can i solve this?
Biswarup GhoshPosted Jul 11, 2012, 3:14 AM
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, 6:59 AM
thanks dear it help full
Kunal VaishyaPosted Jun 6, 2012, 6:59 AM
thanks dear it help full
Kunal VaishyaPosted Jun 6, 2012, 6:59 AM
thanks dear it help full
DMR SantoshPosted Mar 1, 2011, 7:03 AM
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 4, 2010, 3:38 AM
sd fsdfdfssd sd fsdfsdf
MagPosted Aug 2, 2010, 7:18 AM
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, 9:59 AM
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 13, 2009, 3:21 AM
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 28, 2009, 1:15 AM
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