Monday, October 09, 2006 12:21 PM
Who knew how easy it could be?! With .NET 2.0, just use the [System.Windows.Forms.]Clipboard class to get and set clipboard data. Check for data using the Contains methods:
- ContainsText()
- ContainsAudio()
- ContainsFileDropList() -- Drag-and-drop file names...
- ContainsImage()
- ContainsData() -- Check for arbitrary data types specified using DataFormats values
Next, call the corresponding Get method:
- GetText()
- GetAudioStream()
- GetData()
- GetDataObject() -- Nice for interchange within applications
- GetFileDropList()
- GetImage()
You can also call Set methods as above, or Clear to wipe the contents. Very easy to use, very convenient! No more excuse not to leverage the clipboard in your apps.