Clipboard.SetData Method

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

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)

public static void SetData(
	string format,
	Object data


Type: System.String

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

Type: System.Object

An object representing the data to store on the Clipboard.

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

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft