DataObject.GetFormats 메서드

정의

이 데이터 개체의 데이터가 저장되거나 변환될 수 있는 형식 목록을 반환합니다.

오버로드

GetFormats()

이 데이터 개체의 데이터가 저장되거나 변환될 수 있는 형식 목록을 반환합니다.

GetFormats(Boolean)

이 데이터 개체의 데이터가 저장되는 형식의 목록을 반환합니다. Boolean 플래그는 데이터가 자동으로 변환될 수 있는 형식도 포함할지 여부를 나타냅니다.

GetFormats()

이 데이터 개체의 데이터가 저장되거나 변환될 수 있는 형식 목록을 반환합니다.

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

반환

String[]

문자열 배열이며, 각 문자열은 이 데이터 개체에서 지원하는 형식의 이름을 지정합니다.

구현

예제

다음 예제에서는 이 메서드를 사용하여 데이터 개체에서 사용할 수 있는 모든 데이터 형식(네이티브 및 자동 변환 가능)을 나타내는 문자열 배열을 가져옵니다.

DataObject dataObject = new DataObject("Some string data to store...");

// Get an array of strings, each string denoting a data format
// that is available in the data object.  This overload of GetDataFormats
// returns all available data formats, native and auto-convertible.
string[] dataFormats = dataObject.GetFormats();

// Get the number of data formats present in the data object, including both
// auto-convertible and native data formats.
int numberOfDataFormats = dataFormats.Length;

// To enumerate the resulting array of data formats, and take some action when
// a particular data format is found, use a code structure similar to the following.
foreach (string dataFormat in dataFormats)
{
    if (dataFormat == DataFormats.Text)
    {
        // Take some action if/when data in the Text data format is found.
        break;
    }
    else if(dataFormat == DataFormats.StringFormat)
    {
        // Take some action if/when data in the string data format is found.
        break;
    }
}
Dim dataObject As New DataObject("Some string data to store...")

' Get an array of strings, each string denoting a data format
' that is available in the data object.  This overload of GetDataFormats
' returns all available data formats, native and auto-convertible.
Dim dataFormats() As String = dataObject.GetFormats()

' Get the number of data formats present in the data object, including both
' auto-convertible and native data formats.
Dim numberOfDataFormats As Integer = dataFormats.Length

' To enumerate the resulting array of data formats, and take some action when
' a particular data format is found, use a code structure similar to the following.
For Each dataFormat As String In dataFormats
    If dataFormat = System.Windows.DataFormats.Text Then
        ' Take some action if/when data in the Text data format is found.
        Exit For
    ElseIf dataFormat = System.Windows.DataFormats.StringFormat Then
        ' Take some action if/when data in the string data format is found.
        Exit For
    End If
Next dataFormat

설명

미리 정의된 데이터 형식 집합은 DataFormats 클래스를 참조하세요.

적용 대상

GetFormats(Boolean)

이 데이터 개체의 데이터가 저장되는 형식의 목록을 반환합니다. Boolean 플래그는 데이터가 자동으로 변환될 수 있는 형식도 포함할지 여부를 나타냅니다.

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

매개 변수

autoConvert
Boolean

이 데이터 개체의 데이터가 저장되거나 변환될 수 있는 모든 형식을 검색하려면 true이고, 이 데이터 개체의 데이터가 저장된 형식만 검색하려면 false입니다.

반환

String[]

문자열 배열이며, 각 문자열은 이 데이터 개체에서 지원하는 형식의 이름을 지정합니다.

구현

예제

다음 예제에서는 이 메서드를 사용하여 데이터 개체에서 사용할 수 있는 데이터 형식만 나타내는 문자열 배열을 가져옵니다(자동 변환 가능한 데이터 형식이 필터링됨).

DataObject dataObject = new DataObject("Some string data to store...");

// Get an array of strings, each string denoting a data format
// that is available in the data object.  This overload of GetDataFormats
// accepts a Boolean parameter inidcating whether to include auto-convertible
// data formats, or only return native data formats.
string[] dataFormats = dataObject.GetFormats(false /* Include auto-convertible? */);

// Get the number of native data formats present in the data object.
int numberOfDataFormats = dataFormats.Length;

// To enumerate the resulting array of data formats, and take some action when
// a particular data format is found, use a code structure similar to the following.
foreach (string dataFormat in dataFormats)
{
    if (dataFormat == DataFormats.Text)
    {
        // Take some action if/when data in the Text data format is found.
        break;
    }
}
Dim dataObject As New DataObject("Some string data to store...")

' Get an array of strings, each string denoting a data format
' that is available in the data object.  This overload of GetDataFormats
' accepts a Boolean parameter inidcating whether to include auto-convertible
' data formats, or only return native data formats.
Dim dataFormats() As String = dataObject.GetFormats(False) ' Include auto-convertible? 

' Get the number of native data formats present in the data object.
Dim numberOfDataFormats As Integer = dataFormats.Length

' To enumerate the resulting array of data formats, and take some action when
' a particular data format is found, use a code structure similar to the following.
For Each dataFormat As String In dataFormats
    If dataFormat = System.Windows.DataFormats.Text Then
        ' Take some action if/when data in the Text data format is found.
        Exit For
    End If
Next dataFormat

설명

미리 정의된 데이터 형식 집합은 DataFormats 클래스를 참조하세요.

적용 대상