NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DataObject Class

Implements a basic data transfer mechanism.

Object
   DataObject

[Visual Basic]
Public Class DataObject
   Implements IDataObject, IOleDataObject
[C#]
public class DataObject : IDataObject, IOleDataObject
[C++]
public __gc class DataObject : public IDataObject, IOleDataObject
[JScript]
public class DataObject implements IDataObject, IOleDataObject

Remarks

DataObject implements the IDataObject interface, whose methods provide a format-independent mechanism for data transfer. A DataObject is typically used with the system Clipboard and in drag-and-drop operations.

Multiple pieces of data in different formats can be stored in an instance of DataObject. Data is retrieved from the instance by its associated format. Because the target application may not be known, you can increase the likelihood that the data will be in the appropriate format for an application by placing the data in a DataObject in multiple formats. See DataFormats for the predefined formats. You can implement your own format by creating an instance of the DataFormats.Format class.This class can:

To store data in an instance of this class, pass the data to System.WinForms.DataObjects. Call SetData to add data in other formats to an instance of this class. If you want the data you add always to be retrieved in its native format, call SetData with the autoConvert parameter set to false.

Data can be retrieved from a DataObject in any format with which it is compatable with GetData. For example, text can be converted to unicode. To retrieve data in the format in which it was stored, call GetData with the autoConvert parameter set to false.

To determine what formats the data is stored in, call GetFormats. To determine if a format is available, call GetDataPresent with the desired format.

CAUTION   You cannot create a new instance of DataObject with an Object that implements both the IDataObject and Microsoft.Win32.Interop.IOleDataObject interfaces. This causes a design-time or run-time error. To avoid this error, convert the object to either an IDataObject or an IOleDataObject.

Requirements

Namespace: System.WinForms

Assembly: System.WinForms.dll

See Also

DataObject Members | System.WinForms Namespace | Clipboard | IDataObject | DataFormats