Clipboard.ContainsData(String) Metoda

Definicja

Wysyła zapytanie do Schowka pod kątem obecności danych w określonym formacie danych.

public:
 static bool ContainsData(System::String ^ format);
public static bool ContainsData (string format);
static member ContainsData : string -> bool
Public Shared Function ContainsData (format As String) As Boolean

Parametry

format
String

Format danych do wyszukania. Zobacz DataFormats , aby zapoznać się ze wstępnie zdefiniowanymi formatami.

Zwraca

true jeśli dane w określonym formacie są dostępne w Schowku; w przeciwnym razie , false.

Wyjątki

format to null.

Przykłady

W poniższym przykładzie pokazano użycie tej metody.


// 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

Uwagi

Zapytanie dotyczące formatu Bitmap danych lub FileDrop zwróci true , jeśli dane mogą zostać automatycznie przekonwertowane na określony format danych. W przypadku innych formatów danych ta metoda zwraca true wartość tylko wtedy, gdy określony format jest dostępny natywnie w Schowku.

Dotyczy

Zobacz też