Clipboard.GetData(String) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
從剪貼簿中以指定格式檢索資料。
public:
static System::Object ^ GetData(System::String ^ format);
public static object GetData(string format);
public static object? GetData(string format);
static member GetData : string -> obj
Public Shared Function GetData (format As String) As Object
參數
- format
- String
一個字串,用來指定要檢索的資料格式。 關於一組預先定義的資料格式,請參見類別 DataFormats 。
傳回
一個包含指定格式資料的物件,或 null 當資料無法以指定格式取得時。
例外狀況
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