Initializes a new instance of the DataObject class, which can store arbitrary data.
[Visual Basic] Overloads Public Sub New() [C#] public DataObject(); [C++] public: DataObject(); [JScript] public function DataObject();
The new instance provides both the IDataObject and the Microsoft.Win32.Interop.IOleDataObject interfaces.
The following example creates an instance of the DataObject class, and adds data to the instance. Then it retrieves and displays the data. This code assumes Button1 and TextBox1 have been instantiated.
[C#]
private void CreateDataObject2() { //Create a new data object. DataObject myDataObject = new DataObject(); //Add the string to the data object. string myString = "My text string"; myDataObject.SetData(DataFormats.UnicodeText, myString); //Print the string in a text box. textBox1.Text = myDataObject.GetData(DataFormats.Text).ToString(); }
DataObject Class | DataObject Members | System.WinForms Namespace | DataObject Constructor Overload List | GetData | SetData | GetDataPresent