Share via


Clipboard.SetData(String, Object) 方法

定義

以指定的格式將指定的資料儲存在剪貼簿上。

public:
 static void SetData(System::String ^ format, System::Object ^ data);
public static void SetData (string format, object data);
static member SetData : string * obj -> unit
Public Shared Sub SetData (format As String, data As Object)

參數

format
String

會指定資料儲存格式的字串。 如需一組預先定義的資料格式,請參閱 DataFormats 類別。

data
Object

物件,表示要儲存在剪貼簿上的資料。

範例

下列範例示範如何使用這個方法。


// For this example, the data to be placed on the clipboard is a simple
// string.
string textData = "I want to put this string on the clipboard.";

// After this call, the data (string) is placed on the clipboard and tagged
// with a data format of "Text".
Clipboard.SetData(DataFormats.Text, (Object)textData);
' For this example, the data to be placed on the clipboard is a simple
' string.
Dim textData As String = "I want to put this string on the clipboard."

' After this call, the data (string) is placed on the clipboard and tagged
' with a data format of "Text".
Clipboard.SetData(DataFormats.Text, CType(textData, Object))

備註

如果對應的資料格式為 FileDropBitmap ,這個方法會新增已啟用自動轉換的資料。 否則會停用自動轉換。

適用於

另請參閱