IDataObject.GetFormats メソッド
このインスタンスに格納されたデータに関連付けられているすべての形式、または変換できるすべての形式のリストを返します。
オーバーロードの一覧
このインスタンスに格納されたデータに関連付けられているすべての形式、または変換できるすべての形式のリストを返します。
[Visual Basic] Overloads Function GetFormats() As String()
[JScript] function GetFormats() : String[];
インスタンスに格納されているデータが関連付けられている形式、またはそのデータを変換できる形式のリストを取得します。データを変換できる形式をすべて取得するのか、ネイティブ データ形式だけを取得するのかを確認するためにブール値を使用します。
[Visual Basic] Overloads Function GetFormats(Boolean) As String()
[JScript] function GetFormats(Boolean) : String[];
使用例
[Visual Basic, C#, C++] この例では、 IDataObject を実装する DataObject クラスを使用して、 GetFormats メソッドの使用法を示します。最初に、文字列および UnicodeText 形式を使用してデータ オブジェクト (myDataObject
) を作成します。次に、データに関連付けられている形式を取得するために、クエリを 2 回作成します。最初のクエリでは、 autoConvert パラメータを false に指定します。この場合、データのネイティブ形式だけが返されます。2 回目のクエリでは、 autoConvert パラメータを true に設定します。この場合は、データの変換対象となりうる形式を含んでいる形式の一覧を取得します。いずれの場合も、結果の一覧がメッセージ ボックスに表示されます。この例は、 Form1
という名前の Form を作成済みであることを前提にしています。
[Visual Basic, C#, C++] メモ ここでは、GetFormats のオーバーロード形式のうちの 1 つだけについて、使用例を示します。その他の例については、各オーバーロード形式のトピックを参照してください。
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 'GetFormats2
[C#]
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);
}
[C++]
private:
void GetFormats2() {
// Creates a new data object using a string and the UnicodeText format.
DataObject* myDataObject = new DataObject(DataFormats::UnicodeText, S"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 = S"The original format associated with the data is:\n";
for (int i = 0; i < myFormatsArray->Length; i++)
theResult = String::Concat(theResult, myFormatsArray->Item[i], S"\n");
// Gets all data formats and data conversion formats for the data object.
myFormatsArray = myDataObject->GetFormats(true);
// Stores the results in the string.
theResult = String::Concat(theResult,
S"\nThe data format(s) and conversion format(s) associated with the data are:\n");
for (int i = 0; i < myFormatsArray->Length; i++)
theResult = String::Concat(theResult, myFormatsArray->Item[i], S"\n");
// Displays the results.
MessageBox::Show(theResult);
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
参照
IDataObject インターフェイス | IDataObject メンバ | System.Windows.Forms 名前空間