ClipboardProxy.GetText Method

Definition

Retrieves text from the Clipboard.

Overloads

GetText(TextDataFormat)

Retrieves text from the Clipboard.

GetText()

Retrieves text from the Clipboard.

GetText(TextDataFormat)

Source:
ClipboardProxy.vb
Source:
ClipboardProxy.vb
Source:
ClipboardProxy.vb

Retrieves text from the Clipboard.

C#
public string GetText(System.Windows.Forms.TextDataFormat format);

Parameters

format
TextDataFormat

TextDataFormat. If specified, identifies what text format should be retrieved. Default is CommaSeparatedValue. Required.

Returns

The Clipboard text data or an empty string if the Clipboard does not contain data in the specified format.

Examples

This example reads text from the Clipboard into the string textOnClipboard.

VB
Dim textOnClipboard As String = My.Computer.Clipboard.GetText()

This example fails if there is no text on the Clipboard.

Remarks

Possible formats are CommaSeparatedValue, Html, Rtf and UnicodeText.

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

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 5, 6, 7, 8, 9, 10

GetText()

Source:
ClipboardProxy.vb
Source:
ClipboardProxy.vb
Source:
ClipboardProxy.vb

Retrieves text from the Clipboard.

C#
public string GetText();

Returns

The Clipboard text data or an empty string if the Clipboard does not contain data in the Text or UnicodeText format, depending on the operating system.

Examples

This example reads text from the Clipboard into the string textOnClipboard.

VB
Dim textOnClipboard As String = My.Computer.Clipboard.GetText()

This example fails if there is no text on the Clipboard.

Remarks

Possible formats are CommaSeparatedValue, Html, Rtf and UnicodeText.

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

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 5, 6, 7, 8, 9, 10