DataObject.GetFormats Methode

Definition

Gibt eine Liste aller Formate zurück, die den in diesem DataObject gespeicherten Daten zugeordnet sind oder in die diese Daten konvertiert werden können.

Überlädt

GetFormats()

Gibt eine Liste aller Formate zurück, die den in diesem DataObject gespeicherten Daten zugeordnet sind oder in die diese Daten konvertiert werden können.

GetFormats(Boolean)

Gibt eine Liste aller Formate zurück, denen in diesem DataObject gespeicherte Daten zugeordnet sind oder in die diese konvertiert werden können. Dabei wird mithilfe eines Parameters für die automatische Konvertierung bestimmt, ob nur systemeigene Datenformate abgerufen werden sollen oder sämtliche Formate, in die die Daten konvertiert werden können.

GetFormats()

Gibt eine Liste aller Formate zurück, die den in diesem DataObject gespeicherten Daten zugeordnet sind oder in die diese Daten konvertiert werden können.

public:
 virtual cli::array <System::String ^> ^ GetFormats();
public virtual string[] GetFormats ();
abstract member GetFormats : unit -> string[]
override this.GetFormats : unit -> string[]
Public Overridable Function GetFormats () As String()

Gibt zurück

String[]

Ein Array vom Typ String mit einer Liste aller Formate, die von den in diesem Objekt gespeicherten Daten unterstützt werden.

Implementiert

Beispiele

Im folgenden Codebeispiel wird ein DataObject nach den Formaten abgefragt, die den Daten zugeordnet sind, und nach den Formaten, in die die Daten konvertiert werden können. Die resultierende Liste wird in einem Textfeld angezeigt. Dieser Code erfordert, dass textBox1 erstellt wurde.

private:
   void GetAllFormats()
   {
      // Creates a new data object using a string and the text format.
      DataObject^ myDataObject = gcnew DataObject( DataFormats::Text,"Another string" );
      
      // Gets all the data formats and data conversion formats in the DataObject.
      array<String^>^ arrayOfFormats = myDataObject->GetFormats();
      
      // Prints the results.
      textBox1->Text = "The format(s) associated with the data are: \n";
      for ( int i = 0; i < arrayOfFormats->Length; i++ )
      {
         textBox1->Text = String::Concat( textBox1->Text, arrayOfFormats[ i ], "\n" );
      }
   }
private void GetAllFormats() {
    // Creates a new data object using a string and the text format.
    DataObject myDataObject = new DataObject(DataFormats.Text, "Another string");
 
    // Gets all the data formats and data conversion formats in the DataObject.
    String[] arrayOfFormats = myDataObject.GetFormats();
 
    // Prints the results.
    textBox1.Text = "The format(s) associated with the data are: " + '\n';
    for(int i=0; i<arrayOfFormats.Length; i++)
       textBox1.Text += arrayOfFormats[i] + '\n';
 }
Private Sub GetAllFormats()
    ' Creates a new data object using a string and the text format.
    Dim myDataObject As New DataObject(DataFormats.Text, "Another string")
    
    ' Gets all the data formats and data conversion formats in the DataObject.
    Dim arrayOfFormats As String() = myDataObject.GetFormats()
    
    ' 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
End Sub

Hinweise

Rufen Sie diese Methode auf, um die unterstützten Datenformate abzurufen, bevor Sie aufrufen GetData. Die vordefinierten Formate finden Sie unter DataFormats .

Hinweis

Daten können in ein anderes Format konvertiert werden, wenn sie gespeichert wurden, um anzugeben, dass die Konvertierung zulässig ist und wenn das angeforderte Format mit dem gespeicherten Format kompatibel ist. Beispielsweise können als Unicode gespeicherte Daten in Text konvertiert werden.

Weitere Informationen

Gilt für:

GetFormats(Boolean)

Gibt eine Liste aller Formate zurück, denen in diesem DataObject gespeicherte Daten zugeordnet sind oder in die diese konvertiert werden können. Dabei wird mithilfe eines Parameters für die automatische Konvertierung bestimmt, ob nur systemeigene Datenformate abgerufen werden sollen oder sämtliche Formate, in die die Daten konvertiert werden können.

public:
 virtual cli::array <System::String ^> ^ GetFormats(bool autoConvert);
public virtual string[] GetFormats (bool autoConvert);
abstract member GetFormats : bool -> string[]
override this.GetFormats : bool -> string[]
Public Overridable Function GetFormats (autoConvert As Boolean) As String()

Parameter

autoConvert
Boolean

true, wenn alle Formate, denen in diesem DataObject gespeicherte Daten zugeordnet sind, abgerufen werden sollen, oder wenn die Daten in diese Formate konvertiert werden können. false, wenn nur systemeigene Datenformate abgerufen werden sollen.

Gibt zurück

String[]

Ein Array vom Typ String mit einer Liste aller Formate, die von den in diesem Objekt gespeicherten Daten unterstützt werden.

Implementiert

Beispiele

Im folgenden Codebeispiel wird ein DataObject nach den Formaten abfragt, die den Daten zugeordnet sind. Die erste Abfrage gibt den autoConvert Parameter als falsean, sodass nur das native Format der Daten zurückgegeben wird. Die zweite Abfrage gibt den autoConvert Parameter als truean, sodass die Liste der Formate die Formate enthält, in die die Daten konvertiert werden können.

Dieser Code erfordert, dass textBox1 erstellt wurde.

private:
   void GetAllFormats2()
   {
      // Creates a new data object using a string and the text format.
      DataObject^ myDataObject = gcnew DataObject( DataFormats::Text,"Another string" );
      
      // Gets the original data formats in the DataObject.
      array<String^>^ arrayOfFormats = myDataObject->GetFormats( false );
      
      // Prints the results.
      textBox1->Text = "The format(s) associated with the data are: \n";
      for ( int i = 0; i < arrayOfFormats->Length; i++ )
      {
         textBox1->Text = String::Concat( textBox1->Text, arrayOfFormats[ i ], "\n" );
      }
      
      // Gets the all data formats and data conversion formats for the DataObject.
      arrayOfFormats = myDataObject->GetFormats( true );
      
      // Prints the results.
      textBox1->Text = String::Concat( textBox1->Text , "The data formats and conversion ",
         "format(s) associated with the data are: \n" );
      for ( int i = 0; i < arrayOfFormats->Length; i++ )
      {
         textBox1->Text = String::Concat( textBox1->Text, arrayOfFormats[ i ], "\n" );
      }
   }
private void GetAllFormats2() {
    // Creates a new data object using a string and the text format.
    DataObject myDataObject = new DataObject(DataFormats.Text, "Another string");
 
    // Gets the original data formats in the DataObject.
    String[] arrayOfFormats = myDataObject.GetFormats(false);
 
    // Prints the results.
    textBox1.Text = "The format(s) associated with the data are: " + '\n';
    for(int i=0; i<arrayOfFormats.Length; i++)
       textBox1.Text += arrayOfFormats[i] + '\n';
 
    // 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: " + '\n';
    for(int i=0; i<arrayOfFormats.Length; i++)
       textBox1.Text += arrayOfFormats[i] + '\n';
 }
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

Hinweise

Rufen Sie diese Methode auf, um die unterstützten Datenformate abzurufen, bevor Sie aufrufen GetData. Die vordefinierten Formate finden Sie unter DataFormats .

Hinweis

Daten können in ein anderes Format konvertiert werden, wenn sie gespeichert wurden, um anzugeben, dass die Konvertierung zulässig ist und wenn das angeforderte Format mit dem gespeicherten Format kompatibel ist. Beispielsweise können als Unicode gespeicherte Daten in Text konvertiert werden.

Weitere Informationen

Gilt für: