Using Windows Clipboard Programatically


Windows uses clipboard to store data that be transferred from one application to another. Most of the times you use the famous Ctrl+X, Ctrl+C, Ctrl+V keystrokes to cut, copy and paste data. However, sometimes you may want to place some data on the clipboard through code. In such cases you can use Clipboard class to achieve the task. In this code sample you will see how to do just that.

Code Sample

Download the ZIP file and extract it at your end. The file contains a Windows Forms project with one form. The form consists of two textboxes and two buttons. The first textbox and button allows you to enter text and set it to the clipboard. The other textbox and button gets the data from the clipboard and displayes in the second textbox.

Bipin Joshi is an independent software consultant and trainer by profession specializing in Microsoft web development technologies. Having embraced the Yoga way of life he is also a meditation teacher and spiritual guide to his students. He is a prolific author and writes regularly about software development and yoga on his websites. He is programming, meditating, writing, and teaching for over 27 years. To know more about his ASP.NET online courses go here. More details about his Kriya and Meditation online course are available here.

Posted On : 11 July 2004

Tags : .NET Framework Windows Forms