DataObject.GetFormats Metoda

Definice

Vrátí seznam všech formátů, ke kterým jsou data uložená v tomto DataObject formátu přidružená nebo na které lze převést.

Přetížení

Name Description
GetFormats()

Vrátí seznam všech formátů, ke kterým jsou data uložená v tomto DataObject formátu přidružená nebo na které lze převést.

GetFormats(Boolean)

Vrátí seznam všechformátůch DataObject

GetFormats()

Zdroj:
DataObject.cs
Zdroj:
DataObject.cs
Zdroj:
DataObject.cs
Zdroj:
DataObject.cs
Zdroj:
DataObject.cs

Vrátí seznam všech formátů, ke kterým jsou data uložená v tomto DataObject formátu přidružená nebo na které lze převést.

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

Návraty

String[]

Pole typu Stringobsahující seznam všech formátů, které jsou podporovány daty uloženými v tomto objektu.

Implementuje

Příklady

Následující příklad kódu se dotazuje DataObject na formáty přidružené k datům a formáty, na které lze data převést. Výsledný seznam se zobrazí v textovém poli. Tento kód vyžaduje vytvoření textBox1 .

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

Poznámky

Voláním této metody získáte podporované formáty dat před voláním GetData. Viz DataFormats předdefinované formáty.

Note

Data se dají převést do jiného formátu, pokud byla uložena a určuje, že převod je povolený a jestli je požadovaný formát kompatibilní s uloženým formátem. Například data uložená jako Unicode lze převést na text.

Viz také

Platí pro

GetFormats(Boolean)

Zdroj:
DataObject.cs
Zdroj:
DataObject.cs
Zdroj:
DataObject.cs
Zdroj:
DataObject.cs
Zdroj:
DataObject.cs

Vrátí seznam všechformátůch DataObject

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

Parametry

autoConvert
Boolean

true k načtení všech formátů, ke kterým jsou data uložená v této DataObject souvislosti přidružena, nebo je lze převést na; false pro načtení pouze nativních formátů dat.

Návraty

String[]

Pole typu Stringobsahující seznam všech formátů, které jsou podporovány daty uloženými v tomto objektu.

Implementuje

Příklady

Následující příklad kódu se dotazuje DataObject na formáty přidružené k datům. První dotaz určuje autoConvert parametr jako false, takže se vrátí pouze nativní formát dat. Druhý dotaz určuje autoConvert parametr jako true, takže seznam formátů zahrnuje formáty, na které lze data převést.

Tento kód vyžaduje vytvoření textBox1 .

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

Poznámky

Voláním této metody získáte podporované formáty dat před voláním GetData. Viz DataFormats předdefinované formáty.

Note

Data se dají převést do jiného formátu, pokud byla uložena a určuje, že převod je povolený a jestli je požadovaný formát kompatibilní s uloženým formátem. Například data uložená jako Unicode lze převést na text.

Viz také

Platí pro