Data from a Dataobject can be retrieved using the overloads of ‘GetDataPresent()’ method in the DataObject.
The following overloads can be used to retrieve the data from a DataObject.
GetDataPresent (DataFormat) – It first checks whether the data of the specified format is available. If so, it retrieves the data using the ‘GetData(DataFormat)’ method.
GetDataPresent (DataFormat, auto-conversion) – It first checks whether the data of the specified format is available. If so, it retrieves the data using the ‘GetData(DataFormat)’ method. It also filters the auto-convertible data in the DataObject.
A DataObject can be created in three different overloads of the DataObject constructor.
DataObject (object) – In this case, appropriate DataFormat is assigned to the DataObject based on the type of data stored in the object. By default, auto-conversion option is set to ’true’.
[C#]
string mystring = 'Drag and Drop String Object';
DataObject dataobject = new DataObject(mystring);
DataObject (DataFormat, object) – In this case, DataFormat is mentioned when the DataObject is created.
[C#]
string mystring = 'Drag and Drop String Object';
DataObject dataobject = new DataObject(DataFormats.UnicodeText,mystring);
DataObject (DataFormat, Object, auto-conversion) – In this case, DataFormat, Object and Auto-Conversion Boolean value are mentioned when the DataObject is created.
[C#]
string mystring = 'Drag and Drop String Object';
DataObject dataobject = new DataObject(DataFormats.UnicodeText,mystring,false);