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
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
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
Comments
thx :)