System.Windows.Forms.DataObject.GetDataPresent Method

Determines whether this System.Windows.Forms.DataObject contains data in the specified format or, optionally, contains data that can be converted to the specified format.

Syntax

public virtual bool GetDataPresent (string format, bool autoConvert)

Parameters

format
The format to check for. See System.Windows.Forms.DataFormats for predefined formats.
autoConvert
true to determine whether data stored in this System.Windows.Forms.DataObject can be converted to the specified format; false to check whether the data is in the specified format.

Returns

true if the data is in, or can be converted to, the specified format; otherwise, false.

Remarks

Call this method to determine whether a format exists before calling DataObject.GetData(string, bool). Call DataObject.GetFormats(bool) for the formats that are available in this System.Windows.Forms.DataObject.

This method returns true when:

  • The autoConvert parameter is true and the data is in a format that can be converted to the appropriate format.

  • The autoConvert parameter is false and the data is in the appropriate format.

This method returns false when:

  • The autoConvert parameter is true and this method cannot find data in the specified format, and it cannot convert data to the specified format, or the data was stored with automatic conversion set to false.

  • The autoConvert parameter is false and data does not exist in this System.Windows.Forms.DataObject in the specified format.

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.

Note:

If no data can be retrieved, no exception will be thrown. Instead, false will be returned.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0