Edytuj

Udostępnij za pośrednictwem


Clipboard.GetData(String) Method

Definition

Retrieves data in a specified format from the Clipboard.

public:
 static System::Object ^ GetData(System::String ^ format);
public static object GetData (string format);
static member GetData : string -> obj
Public Shared Function GetData (format As String) As Object

Parameters

format
String

A string that specifies the format of the data to retrieve. For a set of predefined data formats, see the DataFormats class.

Returns

An object that contains the data in the specified format, or null if the data is unavailable in the specified format.

Exceptions

format is null.

Examples

The following example demonstrates the use of this method.


// After this line executes, IsHTMLDataOnClipboard will be true if
// HTML data is available natively on the clipboard; if not, it 
// will be false.
bool IsHTMLDataOnClipboard = Clipboard.ContainsData(DataFormats.Html);

// If there is HTML data on the clipboard, retrieve it.
string htmlData;
if(IsHTMLDataOnClipboard)
{

    htmlData = Clipboard.GetText(TextDataFormat.Html);
}

' After this line executes, IsHTMLDataOnClipboard will be true if
' HTML data is available natively on the clipboard; if not, it 
' will be false.
Dim IsHTMLDataOnClipboard As Boolean = Clipboard.ContainsData(DataFormats.Html)

' If there is HTML data on the clipboard, retrieve it.
Dim htmlData As String
If IsHTMLDataOnClipboard Then

    htmlData = Clipboard.GetText(TextDataFormat.Html)

End If

Applies to

See also