Export (0) Print
Expand All

IDataObject Interface

Provides a format-independent mechanism for transferring data.

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

'Declaration
<ComVisibleAttribute(True)> _
Public Interface IDataObject

  NameDescription
Public methodGetData(String)Retrieves the data associated with the specified data format.
Public methodGetData(Type)Retrieves the data associated with the specified class type format.
Public methodGetData(String, Boolean)Retrieves the data associated with the specified data format, using a Boolean to determine whether to convert the data to the format.
Public methodGetDataPresent(String)Determines whether data stored in this instance is associated with, or can be converted to, the specified format.
Public methodGetDataPresent(Type)Determines whether data stored in this instance is associated with, or can be converted to, the specified format.
Public methodGetDataPresent(String, Boolean)Determines whether data stored in this instance is associated with the specified format, using a Boolean value to determine whether to convert the data to the format.
Public methodGetFormatsReturns a list of all formats that data stored in this instance is associated with or can be converted to.
Public methodGetFormats(Boolean)Gets a list of all formats that data stored in this instance is associated with or can be converted to, using a Boolean value to determine whether to retrieve all formats that the data can be converted to or only native data formats.
Public methodSetData(Object)Stores the specified data in this instance, using the class of the data for the format.
Public methodSetData(String, Object)Stores the specified data and its associated format in this instance.
Public methodSetData(Type, Object)Stores the specified data and its associated class type in this instance.
Public methodSetData(String, Boolean, Object)Stores the specified data and its associated format in this instance, using a Boolean value to specify whether the data can be converted to another format.
Top

The IDataObject interface is used by the Clipboard class and in drag-and-drop operations.

When implemented in a class, the IDataObject methods allow the user to store data in multiple formats in an instance of the class. Storing data in more than one format increases the chance that a target application, whose format requirements you might not know, can retrieve the stored data. To store data in an instance of IDataObject, call the SetData method and specify the data format in the format parameter. Set the autoConvert parameter to false if you do not want stored data to be converted to another format when it is retrieved. Invoke SetData multiple times on one instance of IDataObject to store data in more than one format.

You retrieve stored data from an IDataObject by calling the GetData method and specifying the data format in the format parameter. Set the autoConvert parameter to false to retrieve only data that was stored in the specified format. To convert the stored data to the specified format, set autoConvert to true, or do not use autoConvert.

To determine the formats of the data stored in an IDataObject, use the following IDataObject methods.

  • Call the GetFormats method to retrieve an array of all the formats in which the data is available. Set the autoConvert parameter to false to get only the formats in which the data is stored. To get all the formats in which the data is available, set autoConvert to true, or do not use this parameter.

  • Call the GetDataPresent method to determine whether stored data is available in a certain format. If you do not want stored data to be converted to the specified format, set the autoConvert parameter to false.

See the DataObject class for an implementation of this interface. See the DataFormats class for the predefined Clipboard data formats.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft