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 (Type)

Determines whether data stored in this instance is associated with, or can be converted to, the specified format.

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

Parameters

format
A Type representing the format to check for. See DataFormats for predefined formats.

Return Value

true if data stored in this instance is associated with, 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.

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 of the format specified by the format exists in a DataObject, or whether the data can be converted to the specified format. The result is displayed in a MessageBox. The code assumes Button1 has been instantiated.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

   ' Create a new component, which is the data to be stored.
   Dim component1 As Component
   Set component1 = New Component

   ' Create a Type object with the type of the data to be stored.
   Dim type1 As Type
   Set type1 = component1.GetType

   ' Create a DataObject containing the Component object.
   Dim data1 As DataObject
   Set data1 = New DataObject(component1)

   ' Determine if the DataObject contains data of the Type format.
   ' Display the result.
   MessageBox.Show "Is the specified data type present in the DataObject? " & _
      data1.GetDataPresent(type1)

   ' Retrieve the data, using the Type format and display it's type.
   Dim myobj As Object
   Set myobj = data1.GetData(type1)
   MessageBox.Show "The data type stored in the DataObject is: " & myobj.ToString
End Sub

See Also

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