Export (0) Print
Expand All

DataObject.GetFormats Method (Boolean)

Returns a list of all formats that data stored in this DataObject is associated with or can be converted to, using an automatic conversion parameter to determine whether to retrieve only native data formats or all formats that the data can be converted to.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

'Declaration
Public Overridable Function GetFormats ( _
	autoConvert As Boolean _
) As String()

Parameters

autoConvert
Type: System.Boolean

true to retrieve all formats that data stored in this DataObject is associated with, or can be converted to; false to retrieve only native data formats.

Return Value

Type: System.String()
An array of type String, containing a list of all formats that are supported by the data stored in this object.

Implements

IDataObject.GetFormats(Boolean)

Call this method to get the supported data formats before calling GetData. See DataFormats for the predefined formats.

NoteNote

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.

The following code example queries a DataObject for the formats associated with its data. The first query specifies the autoConvert parameter as false, so only the native format of the data is returned. The second query specifies the autoConvert parameter as true, so the list of formats includes the formats that the data can be converted to.

This code requires that textBox1 has been created.

Private Sub GetAllFormats2()
    ' Creates a new data object using a string and the text format. 
    Dim myDataObject As New DataObject(DataFormats.Text, "Another string")

    ' Gets the original data formats in the DataObject. 
    Dim arrayOfFormats As String() = myDataObject.GetFormats(False)

    ' Prints the results.
    textBox1.Text = "The format(s) associated with the data are: " & ControlChars.Cr
    Dim i As Integer 
    For i = 0 To arrayOfFormats.Length - 1
        textBox1.Text += arrayOfFormats(i) + ControlChars.Cr
    Next i 
    ' Gets the all data formats and data conversion formats for the DataObject.
    arrayOfFormats = myDataObject.GetFormats(True)

    ' Prints the results.
    textBox1.Text += "The data formats and conversion format(s) associated with " & _
        "the data are: " & ControlChars.Cr

    For i = 0 To arrayOfFormats.Length - 1
        textBox1.Text += arrayOfFormats(i) + ControlChars.Cr
    Next i
End Sub 'GetAllFormats2 

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft