IDataObject::GetData Method (String^)
Retrieves the data associated with the specified data format.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Parameters
- format
-
Type:
System::String^
The format of the data to retrieve. See DataFormats for predefined formats.
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, this method returns null.
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 compatible with the stored format. For example, data stored as Unicode can be converted to text. |
For an implementation of this method, see DataObject::GetData.
This example uses the DataObject class, which implements IDataObject, to demonstrate the use of the GetData method. The method is used to retrieve the data stored in myDataObject, which is associated with the Text format. The example assumes that you have already created a Form named Form1 and a TextBox named textBox1.
private: void GetData1() { // Creates a new data object using a string and the text format. String^ myString = "My text string"; DataObject^ myDataObject = gcnew DataObject( DataFormats::Text,myString ); // Displays the string in a text box. textBox1->Text = myDataObject->GetData( DataFormats::Text )->ToString(); }
Available since 1.1
