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 (String, Boolean, Object)

Stores the specified data and its associated format in this instance, using autoConvert to specify whether the data can be converted to another format.

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

Parameters

format
The format associated with the data. See DataFormats for predefined formats.
autoConvert
true to allow the data to be converted to another format; otherwise, false.
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.

Example [C#]

The following example stores data in a DataObject and specifies that the data can only be retrieved by its native format.

First, a new DataObject is created. Then, data, in the Unicode format, is stored in the DataObject, with autoConvert set to false.

Then, the DataObject is queried for the list of data formats. Only the Unicode format is returned, although Unicode data can be converted to text and other formats. This code assumes Button1 has been instantiated.

[C#]

private void CreateDataObject2() {
   //Create a new data object.
   DataObject setMyData = 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 | GetData | GetDataPresent | GetFormats | DataFormats