Copying data to the clipboard using C#

So you need to copy data to the clipboard using .net. Usually Ctl-C, Ctl-V is good enough for me. But there arose a need to copy data from a context menu. Microsoft has actually made it pretty easy to get data to/from the clipboard. They have conveniently created a class to do this and called it Clipboard. For my uses I just needed to copy some basic text to the clipboard. To achieve this I simply use the method SetText. Easy as pie!

so a qucik and dirty example is

Clipboard.SetText( "Hello World!");

Will put the text Hello World in your clipboard. There are of course different methods for copying all sorts of data into the clipboard. Read the MSDN for the complete breakdown.

Read the MSDN article


Anonymous said…
hehe, i was looking on how to put data inside the clipboard... turned out to be so easy

thx :)
Anonymous said…
Very good example. Direct to the point.
Anonymous said…
Thanks! Exactly what I needed and super simple.

Popular posts from this blog

C# Form Application in Kiosk Mode/Fullscreen

C# using a transaction with ODBC

Notify Icon Text vs BalloonTipText