IDataObject.GetFormats Metoda

Definice

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

Přetížení

GetFormats()

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

GetFormats(Boolean)

Získá seznam všech formátů, ke kterým jsou data uložená v této instanci přidružená nebo lze je převést, pomocí logické hodnoty určit, zda se mají načíst všechny formáty, na které lze data převést, nebo pouze na nativní datové formáty.

GetFormats()

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

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

Návraty

String[]

Pole názvů, které představuje seznam všech formátů podporovaných daty uloženými v tomto objektu.

Příklady

Tento příklad používá DataObject třídu, která implementuje IDataObject, demonstruje použití GetFormats metody. Nejprve vytvoří datový objekt (myDataObject) pomocí řetězce a Text formátu. Potom načte všechny formáty dat a formáty převodu dat v datovém objektu a zobrazí výsledný seznam v poli se zprávou. Tento příklad předpokládá, že jste vytvořili pojmenovanou Form Form1.

private:
   void GetFormats1()
   {
      // Creates a data object using a string and the Text format.
      DataObject^ myDataObject = gcnew DataObject( DataFormats::Text,"My text string" );
      
      // Gets all the data formats and data conversion formats in the data object.
      array<String^>^allFormats = myDataObject->GetFormats();
      
      // Creates the string that contains the formats.
      String^ theResult = "The format(s) associated with the data are: \n";
      for ( int i = 0; i < allFormats->Length; i++ )
         theResult = theResult + allFormats[ i ] + "\n";
      
      // Displays the result in a message box.
      MessageBox::Show( theResult );
   }
private void GetFormats1() 
{
    // Creates a data object using a string and the Text format.
    DataObject myDataObject = new DataObject(DataFormats.Text, "My text string");
 
    // Gets all the data formats and data conversion formats in the data object.
    String[] allFormats = myDataObject.GetFormats();

    // Creates the string that contains the formats.
    string theResult = "The format(s) associated with the data are: " + '\n';
    for(int i = 0; i < allFormats.Length; i++)
        theResult += allFormats[i] + '\n';
    // Displays the result in a message box.
    MessageBox.Show(theResult);
}
Private Sub GetFormats1()
   ' Creates a data object using a string and the Text format.
   Dim myDataObject As New DataObject(DataFormats.Text, "My text string")
   
   ' Gets all the data formats and data conversion formats in the data object.
   Dim allFormats As [String]() = myDataObject.GetFormats()
   
   ' Creates the string that contains the formats.
   Dim theResult As String = "The format(s) associated with the data are: " & _
                vbCr
   Dim i As Integer
   For i = 0 To allFormats.Length - 1
      theResult += allFormats(i) + vbCr
   Next i 
   ' Displays the result in a message box.
   MessageBox.Show(theResult)
End Sub

Poznámky

Voláním této metody získejte podporované formáty dat před voláním GetData metody. Podívejte se na DataFormats třídu pro předdefinované formáty.

Poznámka

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

Implementace této metody naleznete v tématu DataObject.GetFormats.

Viz také

Platí pro

GetFormats(Boolean)

Získá seznam všech formátů, ke kterým jsou data uložená v této instanci přidružená nebo lze je převést, pomocí logické hodnoty určit, zda se mají načíst všechny formáty, na které lze data převést, nebo pouze na nativní datové formáty.

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

Parametry

autoConvert
Boolean

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

Návraty

String[]

Pole názvů, které představuje seznam všech formátů podporovaných daty uloženými v tomto objektu.

Příklady

Tento příklad používá DataObject třídu, která implementuje IDataObject, demonstruje použití GetFormats metody. Nejprve vytvoří datový objekt (myDataObject) pomocí řetězce a UnicodeText formátu. Pak vytvoří dva dotazy, které získají formáty přidružené k datům. V prvním dotazu nastaví autoConvert parametr na false : v tomto případě se vrátí pouze nativní formát dat. V druhém dotazu nastaví autoConvert parametr na true, aby získal seznam formátů, včetně formátů, na které lze data převést. V každém případě se výsledný seznam zobrazí v poli se zprávou. Tento příklad předpokládá, že jste vytvořili pojmenovanou Form Form1.

private:
   void GetFormats2()
   {
      // Creates a new data object using a string and the UnicodeText format.
      DataObject^ myDataObject = gcnew DataObject( DataFormats::UnicodeText,"My text string" );
      
      // Gets the original data formats in the data object by setting the automatic
      // conversion parameter to false.
      array<String^>^myFormatsArray = myDataObject->GetFormats( false );
      
      // Stores the results in a string.
      String^ theResult = "The original format associated with the data is:\n";
      for ( int i = 0; i < myFormatsArray->Length; i++ )
         theResult = theResult + myFormatsArray[ i ] + "\n";
      
      // Gets all data formats and data conversion formats for the data object.
      myFormatsArray = myDataObject->GetFormats( true );
      
      // Stores the results in the string.
      theResult = theResult + "\nThe data format(s) and conversion format(s) associated with the data are:\n";
      for ( int i = 0; i < myFormatsArray->Length; i++ )
         theResult = theResult + myFormatsArray[ i ] + "\n";
      
      // Displays the results.
      MessageBox::Show( theResult );
   }
private void GetFormats2() 
{
    // Creates a new data object using a string and the UnicodeText format.
    DataObject myDataObject = new DataObject(DataFormats.UnicodeText, "My text string");

    // Gets the original data formats in the data object by setting the automatic
    // conversion parameter to false.
    String[] myFormatsArray = myDataObject.GetFormats(false);

    // Stores the results in a string.
    string theResult = "The original format associated with the data is:\n";
    for(int i = 0; i < myFormatsArray.Length; i++)
        theResult += myFormatsArray[i] + '\n';

    // Gets all data formats and data conversion formats for the data object.
    myFormatsArray = myDataObject.GetFormats(true);
 
    // Stores the results in the string.
    theResult += "\nThe data format(s) and conversion format(s) associated with " +
        "the data are:\n";
    for(int i = 0; i < myFormatsArray.Length; i++)
        theResult += myFormatsArray[i] + '\n';

    // Displays the results.
    MessageBox.Show(theResult);
}
Private Sub GetFormats2()
   ' Creates a new data object using a string and the UnicodeText format.
   Dim myDataObject As New DataObject(DataFormats.UnicodeText, "My text string")
   
   ' Gets the original data formats in the data object by setting the automatic
   ' conversion parameter to false.
   Dim myFormatsArray As [String]() = myDataObject.GetFormats(False)
   
   ' Stores the results in a string.
   Dim theResult As String = "The original format associated with the data is:" & vbCr
   Dim i As Integer
   For i = 0 To myFormatsArray.Length - 1
      theResult += myFormatsArray(i) + vbCr
   Next i 
   ' Gets all data formats and data conversion formats for the data object.
   myFormatsArray = myDataObject.GetFormats(True)
   
   ' Stores the results in the string.
   theResult += vbCr + "The data format(s) and conversion format(s) associated with " & _
     "the data are:" & vbCr
   For i = 0 To myFormatsArray.Length - 1
      theResult += myFormatsArray(i) + vbCr
   Next i
   ' Displays the results.
   MessageBox.Show(theResult)
End Sub

Poznámky

Voláním této metody získejte podporované formáty dat před voláním GetData metody. Podívejte se na DataFormats třídu pro předdefinované formáty.

Poznámka

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

Implementace této metody naleznete v tématu DataObject.GetFormats.

Viz také

Platí pro