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 Constructor (Object)

Initializes a new instance of the DataObject class, containing the specified data.

[Visual Basic]
Overloads Public Sub New( _
   ByVal data As Object _
)
[C#]
public DataObject(
   object data
);
[C++]
public: DataObject(
   Object* data
);
[JScript]
public function DataObject(
   data : Object
);

Parameters

data
The data to store.

Remarks

The new instance provides both the IDataObject and the Microsoft.Win32.Interop.IOleDataObject interfaces for the specified data.

CAUTION   Creating an instance of DataObject with an object that implements both the IDataObject and Microsoft.Win32.Interop.IOleDataObject interfaces causes a design-time or run-time error. To avoid this problem, first convert the object either to an IDataObject or to an Microsoft.Win32.Interop.IOleDataObject.

Example [C#]

The following example creates an instance of DataObject that contains a string. Because no class format is specified, the assumed class for the data is Object. The data is retrieved using its class as the format. The results displayed in a text box. This code assumes Button1 and TextBox1 have been instantiated.

[C#]

private void CreateDataObject3() {
   //Create a new data object using a string.
   string myString = "My text string";
   DataObject myDataObject = new DataObject(myString);

   //Print the string in a text box.
   textBox1.Text = myDataObject.GetData("System.String").ToString();
}

See Also

DataObject Class | DataObject Members | System.WinForms Namespace | DataObject Constructor Overload List | GetData | SetData | GetDataPresent