Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Clipboard Class
Clipboard Methods
 SetData Method
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Clipboard..::.SetData Method

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

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)
Visual Basic (Declaration)
Public Shared Sub SetData ( _
    format As String, _
    data As Object _
)
Visual Basic (Usage)
Dim format As String
Dim data As Object

Clipboard.SetData(format, data)
C#
public static void SetData(
    string format,
    Object data
)
Visual C++
public:
static void SetData(
    String^ format, 
    Object^ data
)
JScript
public static function SetData(
    format : String, 
    data : Object
)
XAML
You cannot use methods in XAML.

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.

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

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker