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