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

Determines whether data stored in this instance is associated with the specified format, using autoConvert to determine whether to convert the data to the format.

[Visual Basic]
Overloads Overridable Public Function GetDataPresent( _
   ByVal format As String, _
   ByVal autoConvert As Boolean _
) As Boolean
[C#]
public virtual bool GetDataPresent(
   string format,
   bool autoConvert
);
[C++]
public: virtual bool GetDataPresent(
   String* format,
   bool autoConvert
);
[JScript]
public function GetDataPresent(
   format : String,
   autoConvert : Boolean
) : Boolean;

Parameters

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

Return Value

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 in this DataObject instance before calling GetData. Call GetFormats for the formats that are available in this instance.

This method returns true when:

This method returns false when:

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

The following example determines whether data currently stored in this Object is associated with a specified format. First, a new instance of DataObject is initialized with a string, specifying its associated format as text. Then the DataObject is queried for data associated with the text format, specifying autoConvert false. The result of this query is true. Then the DataObject is queried for data associated with unicode format, specifying autoConvert false. Text can be converted to unicode but, because conversion is not allowed, the result of this query is false. This code assumes Button1 has been instantiated.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
   ' Declare a DataObject.
   Dim data1 As DataObject
   ' Define a string.
   Dim textString1 As String  = "My text string"
   ' Define a boolean to hold the query results.
   Dim isFormat As Boolean
   ' Create a new DataObject containing the text string whose associated format is specified as text.
   Set data1 = New DataObject(DataFormats.Text, textString1)
   ' Query the DataObject for text format, specifying no conversion.
   isFormat = data1.GetDataPresent(DataFormats.Text, false)
   ' And display the result of the query.
   messagebox.Show "Data associated with text format was found: " & isFormat
   ' Now query for unicode format, specifying no conversion.
   isFormat = data1.GetDataPresent(DataFormats.UnicodeText, false)
   ' And display the result of the query.
   MessageBox.Show "Data associated with unicode format was found: " & isFormat
End Sub

See Also

DataObject Class | DataObject Members | System.WinForms Namespace | DataObject.GetDataPresent Overload List | SetData | System.DataObject.GetData | DataFormats | GetFormats