Clipboard.SetData Method (String, Object)

 

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
)

Parameters

format
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.

data
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
Available since 3.0
Return to top
Show: