DataObject.GetData Method (String)
Returns the data associated with the specified data format.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
abstract GetData : format:string -> Object override GetData : format:string -> Object
Return ValueType: System.Object
The data associated with the specified format, or null.
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 automatic conversion set to false, 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 DataObject.
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.
When format is Html, this method returns a UTF-8 encoded string in applications that target .NET 4.5 or higher, and an ANSI encoded string in applications that target .NET 4.0 or lower.
The following code 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 a string, and displayed in a text box.
This code requires that textBox1 has been created.
Available since 1.1