Clipboard.ContainsData(String) Methode

Definition

Fragt die Zwischenablage nach dem Vorhandensein von Daten in einem angegebenen Datenformat ab.

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

Parameter

format
String

Das Format der daten, nach der gesucht werden soll. Informationen zu vordefinierten Formaten finden Sie DataFormats unter

Gibt zurück

truewenn Daten im angegebenen Format in der Zwischenablage verfügbar sind; andernfalls . false

Ausnahmen

format ist null.

Beispiele

Im folgenden Beispiel wird die Verwendung dieser Methode veranschaulicht.


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

Hinweise

Eine Abfrage für das Datenformat Bitmap oder FileDrop gibt zurück true , wenn die Daten automatisch in das angegebene Datenformat konvertiert werden können. Bei anderen Datenformaten gibt diese Methode nur dann zurück true , wenn das angegebene Format nativ in der Zwischenablage verfügbar ist.

Gilt für:

Weitere Informationen