語言

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

備註

此方法加入資料時,若對應的資料格式為 FileDrop 或 Bitmap,則啟用自動轉換。 否則,自動轉換功能將被關閉。

適用於

另請參閱