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.SetData (Type, Object)

Stores the specified data and its associated class type in this instance.

[Visual Basic]
Overloads Overridable Public Sub SetData( _
   ByVal format As Type, _
   ByVal data As Object _
)
[C#]
public virtual void SetData(
   Type format,
   object data
);
[C++]
public: virtual void SetData(
   Type* format,
   Object* data
);
[JScript]
public function SetData(
   format : Type,
   data : Object
);

Parameters

format
A Type representing the format associated with the data. See DataFormats for predefined formats.
data
The data to store.

Remarks

If you do not know the format of the target application, you can store data in multiple formats using this method.

Data stored using this method can be converted to a compatible format when it is retrieved.

Example [C#]

The following example stores data in a DataObject using a Type to specify the data format.

First, a new DataObject is created. Then this method stores data in the new instance, using a Type as the data format. The data is then retrieved by calling GetData using the Type to specify the data format. The result is displayed in a MessageBox.

This code assumes Button1 has been instantiated.

[C#]

private void SetMyData3() {
   //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();
}

See Also

DataObject Class | DataObject Members | System.WinForms Namespace | DataObject.SetData Overload List | GetDataPresent | GetData | DataFormats | GetFormats | Type