IDataObject.GetFormats メソッド ()

このインスタンスに格納されたデータに関連付けられているすべての形式、または変換できるすべての形式のリストを返します。

Function GetFormats() As String()
[C#]
string[] GetFormats();
[C++]
String* GetFormats()  __gc[];
[JScript]
function GetFormats() : String[];

戻り値

オブジェクトに格納されているデータがサポートする形式すべてのリストを表す名前の配列。

解説

サポートされているデータ形式を取得するには、 GetData を呼び出す前に、このメソッドを呼び出します。定義済みの形式については、 DataFormats クラスのトピックを参照してください。

メモ   形式変換を有効にしてデータが格納されている場合、要求した形式が、格納されている形式と互換性があれば、そのデータを別の形式に変換できます。たとえば、Unicode として格納されたデータをテキストに変換できます。

このメソッドの実装については、 DataObject.GetFormats のトピックを参照してください。

使用例

[Visual Basic, C#, C++] この例では、 IDataObject を実装する DataObject クラスを使用して、 GetFormats メソッドの使用法を示します。最初に、文字列および Text 形式を使用してデータ オブジェクト (myDataObject) を作成します。次に、データ オブジェクトのすべてのデータ形式およびデータ変換形式を取得し、結果の一覧をメッセージ ボックスに表示します。この例は、 Form1 という名前の Form を作成済みであることを前提にしています。

 
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 'GetFormats1

[C#] 
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);
}

[C++] 
private:
    void GetFormats1() {
        // Creates a data object using a string and the Text format.
        DataObject* myDataObject = new DataObject(DataFormats::Text, S"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 = S"The format(s) associated with the data are: \n";
        for (int i = 0; i < allFormats->Length; i++)
            theResult = String::Concat(theResult, allFormats->Item[i], S"\n");
        // Displays the result in a message box.
        MessageBox::Show(theResult);
    }

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

IDataObject インターフェイス | IDataObject メンバ | System.Windows.Forms 名前空間 | IDataObject.GetFormats オーバーロードの一覧 | DataObject.GetFormats | DataObject.GetData