语言

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,则此方法添加启用自动转换的数据。 否则,将禁用自动转换。

适用于

另请参阅