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.GetFormats

Gets a list of all formats that data stored in this instance is associated with or can be converted to.

Overload List

Gets a list of all formats that data stored in this instance is associated with or can be converted to.

[Visual Basic] Overloads Overridable Public Function GetFormats() As String ()
[C#] public virtual string[] GetFormats();
[C++] public: virtual String* GetFormats() [];
[JScript] public function GetFormats() : String[];

Gets a list of all formats that data stored in this instance is associated with or can be converted to, using autoConvert to determine whether to retrieve all formats that the data can be converted to or only native data formats.

[Visual Basic] Overloads Overridable Public Function GetFormats(Boolean) As String ()
[C#] public virtual string[] GetFormats(bool);
[C++] public: virtual String* GetFormats(bool) [];
[JScript] public function GetFormats(Boolean) : String[];

Example

The following example queries a DataObject for the formats associated with its data. The first query specifies autoConvert as false, so only the native format of the data is returned.

The second query specifies autoConvert as true, so the list of formats includes the formats that the data can be converted to. This code assumes Button1 has been instantiated.

Note   This example shows how to use one of the overloaded versions of GetFormats. For other examples that may be available, see the individual overload topics.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
   ' Create a new DataObject containing data associated with text format.
   Dim data1 As DataObject
   Set data1 = New DataObject(DataFormats.Text, "My format test string")

   ' Declare an array of strings to hold data formats.
   Dim arrayOfFormats() As String

   ' Query the DataObject for only the stored data formats and display the results.
   arrayOfFormats = data1.GetFormats(False)
   ' Declare a variable to interate through the array.
   Dim i As Integer
   ' Declare a string to display formats.
   Dim displayFormats As String
   For i = LBound(arrayOfFormats) To UBound(arrayOfFormats)
       displayFormats &= arrayOfFormats(i) & vbnewline
   Next
   MessageBox.Show "The format(s) associated with the data are: " & displayFormats

   ' Query the DataObject for the data formats and the data conversion formats.
   arrayofformats = data1.GetFormats(True)
   ' And display the formats.
   displayFormats = ""
   For i = LBound(arrayOfFormats) To UBound(arrayOfFormats)
      displayFormats &= arrayOfFormats(i) & vbnewline
   Next
   MessageBox.Show "The format(s) associated with or that " & _
      "the data can be converted to are: " & displayFormats
End Sub

See Also

DataObject Class | DataObject Members | System.WinForms Namespace