ClipboardProxy.SetText Method

Definition

Writes text to the Clipboard.

Overloads

SetText(String)

Writes text to the Clipboard.

SetText(String, TextDataFormat)

Writes text to the Clipboard.

SetText(String)

Writes text to the Clipboard.

public:
 void SetText(System::String ^ text);
public void SetText (string text);
member this.SetText : string -> unit
Public Sub SetText (text As String)

Parameters

text
String

String. Text to be written. Required.

Exceptions

text is an empty string.

text is Nothing.

Examples

This example writes the string This is a test string. to the Clipboard.

My.Computer.Clipboard.SetText("This is a test string.")

Remarks

Possible formats are CommaSeparatedValue, Html, Rtf and UnicodeText.

Previous Clipboard formats are not preserved.

Important

Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data.

Availability by Project Type

Project type Available
Windows Application Yes
Class Library Yes
Console Application Yes
Windows Control Library Yes
Web Control Library No
Windows Service Yes
Web Site No

See also

Applies to

SetText(String, TextDataFormat)

Writes text to the Clipboard.

public:
 void SetText(System::String ^ text, System::Windows::Forms::TextDataFormat format);
public void SetText (string text, System.Windows.Forms.TextDataFormat format);
member this.SetText : string * System.Windows.Forms.TextDataFormat -> unit
Public Sub SetText (text As String, format As TextDataFormat)

Parameters

text
String

String. Text to be written. Required.

format
TextDataFormat

TextDataFormat. Format to be used when writing text. Default is UnicodeText. Required.

Exceptions

text is an empty string.

text is Nothing.

Examples

This example writes the string This is a test string. to the Clipboard.

My.Computer.Clipboard.SetText("This is a test string.")

Remarks

Possible formats are CommaSeparatedValue, Html, Rtf and UnicodeText.

Previous Clipboard formats are not preserved.

Important

Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data.

Availability by Project Type

Project type Available
Windows Application Yes
Class Library Yes
Console Application Yes
Windows Control Library Yes
Web Control Library No
Windows Service Yes
Web Site No

See also

Applies to