Clipboard.SetData(String, Object) 方法

定義

以指定的格式將指定的資料儲存在剪貼簿上。Stores the specified data on the Clipboard in the specified format.

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

會指定資料儲存格式的字串。A string that specifies the format to use to store the data. 如需一組預先定義的資料格式,請參閱 DataFormats 類別。See the DataFormats class for a set of predefined data formats.

data
Object

物件,表示要儲存在剪貼簿上的資料。An object representing the data to store on the Clipboard.

範例

下列範例示範如何使用這個方法。The following example demonstrates the use of this method.


// 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,則這個方法會加入已啟用自動轉換的資料。This method adds data with auto-conversion enabled if the corresponding data format is FileDrop or Bitmap. 否則,自動轉換會停用。Otherwise, auto-conversion is disabled.

適用於

另請參閱