Clipboard::SetData Method (String^, Object^)
Clears the Clipboard and then adds data in the specified format.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Parameters
- format
-
Type:
System::String^
The format of the data to set. See DataFormats for predefined formats.
- data
-
Type:
System::Object^
An Object representing the data to add.
| Exception | Condition |
|---|---|
| ExternalException | The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. |
| ThreadStateException | The current thread is not in single-threaded apartment (STA) mode. Add the STAThreadAttribute to your application's Main method. |
| ArgumentNullException | data is null. |
If you do not know the format of the target application, you can store data in multiple formats using this method.
Data stored using this method can be converted to a compatible format when it is retrieved.
To retrieve data from the Clipboard in a particular format, first use the ContainsData method to determine whether the Clipboard contains data in that format before retrieving it with the GetData method.
Note |
|---|
The Clipboard class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your Main method is marked with the STAThreadAttribute attribute. |
for adding data to the system Clipboard that is of type String or is in one of the following data formats: Text, UnicodeText, or CommaSeparatedValue. Associated enumeration: UIPermissionClipboard::OwnClipboard
for adding data of any type or format to the system Clipboard. Associated enumeration: UIPermissionClipboard::AllClipboard
Available since 2.0
