Clipboard.SetData(String, Object) Method

Definition

Stores the specified data on the Clipboard in the specified format.

C#
public static void SetData(string format, object data);

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.

C#

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

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

Tuote Versiot
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also