System.Windows.Forms.Clipboard.SetData Method

Clears the Clipboard and then adds data in the specified format.

Syntax

public static void SetData (string format, object data)

Parameters

format
The format of the data to set. See System.Windows.Forms.DataFormats for predefined formats.
data
An object representing the data to add.

Remarks

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 Clipboard.ContainsData(string) method to determine whether the Clipboard contains data in that format before retrieving it with the Clipboard.GetData(string) method.

Note:

The System.Windows.Forms.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.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0