Places data on the system Clipboard. using copy to specify whether the data should remain on the Clipboard after the application exits.
[Visual Basic] Overloads Public Shared Sub SetDataObject( _ ByVal data As Object, _ ByVal copy As Boolean _ ) [C#] public static void SetDataObject( object data, bool copy ); [C++] public: static void SetDataObject( Object* data, bool copy ); [JScript] public static function SetDataObject( data : Object, copy : Boolean );
Exception Type | Condition |
---|---|
Exception | Data could not be placed on the Clipboard. The exception can occur because another application has the Clipboard open. |
When the copy parameter is true, the data will remain on the Clipboard after the application has exited.
When copy is false, the data will be deleted from system Clipboard when the application exits.
The following example places a persistent copy of the selected text data in the text box on the system Clipboard. This code assumes Button3 and TextBox1 have been instantiated.
[Visual Basic]
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 'Take the selected text from a text box and put it on the clipboard. Clipboard.SetDataObject(TextBox1.SelectedText, True) End Sub
Clipboard Class | Clipboard Members | System.WinForms Namespace | Clipboard.SetDataObject Overload List | DataObject | DataFormats | IDataObject | GetDataObject