Clipboard.ContainsData(String) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
查詢剪貼簿是否有指定資料格式的資料。
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
參數
- format
- String
要注意的資料格式。 請參閱 DataFormats 預設格式。
傳回
true如果剪貼簿上有指定格式的資料;否則,。 false
例外狀況
format 是 null。
範例
以下範例展示了此方法的使用。
// 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
備註
查詢資料格式BitmapFileDrop或資料是否true能自動轉換成指定的資料格式。 對於其他資料格式,只有當指定格式在剪貼簿上原生可用時,此方法才會回傳 true 。