System.Windows.Forms.Clipboard.SetText Method

Clears the Clipboard and then adds text data in the format indicated by the specified System.Windows.Forms.TextDataFormat value.

Syntax

public static void SetText (string text, TextDataFormat format)

Parameters

text
The text to add to the Clipboard.
format
One of the System.Windows.Forms.TextDataFormat values.

Remarks

To retrieve text data from the Clipboard, first use the erload:System.Windows.Forms.Clipboard.ContainsText method to determine whether the Clipboard contains text data before retrieving it with the erload:System.Windows.Forms.Clipboard.GetText 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