IDataObject.GetFormats 메서드

정의

이 인스턴스에 저장된 데이터와 관련되어 있거나 해당 데이터를 변환할 수 있는 모든 형식의 목록을 반환합니다.

오버로드

GetFormats()

이 인스턴스에 저장된 데이터와 관련되어 있거나 해당 데이터를 변환할 수 있는 모든 형식의 목록을 반환합니다.

GetFormats(Boolean)

부울 값을 통해 데이터가 변환될 수 있는 모든 형식을 검색할지 또는 네이티브 데이터 형식만 검색할지를 결정하여 이 인스턴스에 저장된 데이터와 관련되어 있거나 해당 데이터를 변환할 수 있는 모든 형식의 목록을 가져옵니다.

GetFormats()

이 인스턴스에 저장된 데이터와 관련되어 있거나 해당 데이터를 변환할 수 있는 모든 형식의 목록을 반환합니다.

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

반환

String[]

이 개체에 저장된 데이터가 지원하는 모든 형식의 목록을 나타내는 이름의 배열입니다.

예제

이 예제에서는 구현하는 클래스를 IDataObject사용하여 DataObject 메서드의 사용을 보여 줍니다GetFormats. 먼저 문자열 및 형식을 사용하여 데이터 개체(myDataObject)를 Text 만듭니다. 그런 다음 데이터 개체의 모든 데이터 형식 및 데이터 변환 형식을 검색하고 결과 목록을 메시지 상자에 표시합니다. 이 예제에서는 명명Form1된 이름을 만들었다고 가정합니다Form.

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

설명

메서드를 호출하기 전에 이 메서드를 호출하여 지원되는 데이터 형식을 GetData 가져옵니다. DataFormats 미리 정의된 형식에 대한 클래스를 참조하세요.

참고

변환이 허용되도록 지정하고 요청된 형식이 저장된 형식과 호환되는 경우 데이터를 다른 형식으로 변환할 수 있습니다. 예를 들어 유니코드로 저장된 데이터를 텍스트로 변환할 수 있습니다.

이 메서드를 구현 하는 것을 참조 하세요. DataObject.GetFormats합니다.

추가 정보

적용 대상

GetFormats(Boolean)

부울 값을 통해 데이터가 변환될 수 있는 모든 형식을 검색할지 또는 네이티브 데이터 형식만 검색할지를 결정하여 이 인스턴스에 저장된 데이터와 관련되어 있거나 해당 데이터를 변환할 수 있는 모든 형식의 목록을 가져옵니다.

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

매개 변수

autoConvert
Boolean

이 인스턴스에 저장된 데이터와 관련되어 있거나 해당 데이터를 변환할 수 있는 모든 형식을 검색하려면 true이고, 네이티브 데이터 형식만 검색하려면 false입니다.

반환

String[]

이 개체에 저장된 데이터가 지원하는 모든 형식의 목록을 나타내는 이름의 배열입니다.

예제

이 예제에서는 구현하는 클래스를 IDataObject사용하여 DataObject 메서드의 사용을 보여 줍니다GetFormats. 먼저 문자열 및 형식을 사용하여 데이터 개체(myDataObject)를 UnicodeText 만듭니다. 그런 다음 데이터와 연결된 형식을 가져오기 위해 두 개의 쿼리를 만듭니다. 첫 번째 쿼리에서는 매개 변수를 autoConvert 다음과 같이 false 설정합니다. 이 경우 데이터의 네이티브 형식만 반환됩니다. 두 번째 쿼리에서는 데이터를 변환할 true수 있는 형식을 포함하여 형식 목록을 가져오도록 매개 변수를 설정합니다autoConvert. 각 경우에 결과 목록이 메시지 상자에 표시됩니다. 이 예제에서는 명명Form1된 이름을 만들었다고 가정합니다Form.

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

설명

메서드를 호출하기 전에 이 메서드를 호출하여 지원되는 데이터 형식을 GetData 가져옵니다. DataFormats 미리 정의된 형식에 대한 클래스를 참조하세요.

참고

변환이 허용되도록 지정하고 요청된 형식이 저장된 형식과 호환되는 경우 데이터를 다른 형식으로 변환할 수 있습니다. 예를 들어 유니코드로 저장된 데이터를 텍스트로 변환할 수 있습니다.

이 메서드를 구현 하는 것을 참조 하세요. DataObject.GetFormats합니다.

추가 정보

적용 대상