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.GetData (String)

Retrieves the data associated with the specified data format.

[Visual Basic]
Overloads Overridable Public Function GetData( _
   ByVal format As String _
) As Object
[C#]
public virtual object GetData(
   string format
);
[C++]
public: virtual Object* GetData(
   String* format
);
[JScript]
public function GetData(
   format : String
) : Object;

Parameters

format
The format of the data to retrieve. See DataFormats for predefined formats.

Return Value

The data associated with the specified format, or a null reference (in Visual Basic Nothing).

Remarks

If this method cannot find data in the specified format, it attempts to convert the data to the format. If the data cannot be converted to the specified format, or if the data was stored with autoConvert set to false, this method returns a null reference (Nothing).

To determine whether data is associated with, or can be converted to, a format, call GetDataPresent before calling GetData. Call GetFormats for a list of valid formats for the data stored in this instance.

Note   Data can be converted to another format if it was stored specifying that conversion is allowed, and if the requested format is compatable with the stored format. For example, data stored as Unicode can be converted to text.

Example [C#]

The following example retrieves the data stored in a DataObject.

First, a new DataObject is created with text data. Then, the data is retrieved, specifying its format as text, and displayed in a text box.

Next, we retrieve the data again, specifying its format as Unicode, which is a format that text can be converted to. The data is displayed in a text box.

This code assumes Button1 and TextBox1 have been instantiated.

[C#]

private void GetMyData2() {
   //Create a new data object using a string and the text format.
   string myString = "My text string";
   DataObject myDataObject = new DataObject(DataFormats.Text, 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.GetData Overload List | SetData | GetDataPresent | DataFormats | System.WinForms.GetFormats