แก้ไข

แชร์ผ่าน


Clipboard.SetData(String, Object) Method

Definition

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)

Parameters

format
String

A string that specifies the format to use to store the data. See the DataFormats class for a set of predefined data formats.

data
Object

An object representing the data to store on the Clipboard.

Examples

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

Remarks

This method adds data with auto-conversion enabled if the corresponding data format is FileDrop or Bitmap. Otherwise, auto-conversion is disabled.

Applies to

See also