DataObject.GetDataPresent 메서드

정의

지정된 형식으로 데이터를 사용할 수 있는지 또는 변환할 수 있는지 여부를 결정합니다.

오버로드

Name Description
GetDataPresent(String)

문자열에 지정된 형식으로 데이터를 사용할 수 있는지 또는 변환할 수 있는지 여부를 결정합니다.

GetDataPresent(Type)

개체에서 지정 Type 한 형식으로 데이터를 사용할 수 있는지 또는 변환할 수 있는지 여부를 결정합니다.

GetDataPresent(String, Boolean)

지정된 형식으로 데이터를 사용할 수 있는지 또는 변환할 수 있는지 여부를 결정합니다. 플래그는 Boolean 데이터를 해당 형식으로 사용할 수 없는 경우 지정된 형식으로 변환할 수 있는지 여부를 나타냅니다.

설명

호출 GetDataPresent 하여 호출 GetData하기 전에 이 데이터 개체에서 형식을 사용할 수 있는지 여부를 확인합니다. 이 데이터 개체에서 사용할 수 있는 모든 형식의 목록을 가져오려면 호출 GetFormats 합니다.

GetDataPresent(String)

문자열에 지정된 형식으로 데이터를 사용할 수 있는지 또는 변환할 수 있는지 여부를 결정합니다.

public:
 virtual bool GetDataPresent(System::String ^ format);
public bool GetDataPresent(string format);
abstract member GetDataPresent : string -> bool
override this.GetDataPresent : string -> bool
Public Function GetDataPresent (format As String) As Boolean

매개 변수

format
String

데이터의 형식을 지정하는 문자열입니다. 미리 정의된 데이터 형식 집합은 클래스를 DataFormats 참조하세요.

반품

true데이터가 지정된 형식에 있거나 변환될 수 있으면 입니다. 그렇지 않으면 . false

구현

예외

formatnull입니다.

예제

다음 예제에서는 이 메서드를 사용하여 설명자 문자열로 특정 데이터 형식이 있는지 쿼리합니다.

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

// Query for the presence of Text data in the data object, by a data format descriptor string.
// In this overload of GetDataPresent, the method will return true both for native data formats
// and when the data can automatically be converted to the specifed format.

// In this case, string data is present natively, so GetDataPresent returns "true".
string textData = null;
if (dataObject.GetDataPresent(DataFormats.StringFormat))
{
    textData = dataObject.GetData(DataFormats.StringFormat) as string;
}

// In this case, the Text data in the data object can be autoconverted to 
// Unicode text, so GetDataPresent returns "true".
byte[] unicodeData = null;
if (dataObject.GetDataPresent(DataFormats.UnicodeText))
{
    unicodeData = dataObject.GetData(DataFormats.UnicodeText) as byte[];
}
Dim dataObject As New DataObject("Some string data to store...")

' Query for the presence of Text data in the data object, by a data format descriptor string.
' In this overload of GetDataPresent, the method will return true both for native data formats
' and when the data can automatically be converted to the specifed format.

' In this case, string data is present natively, so GetDataPresent returns "true".
Dim textData As String = Nothing
If dataObject.GetDataPresent(DataFormats.StringFormat) Then
    textData = TryCast(dataObject.GetData(DataFormats.StringFormat), String)
End If

' In this case, the Text data in the data object can be autoconverted to 
' Unicode text, so GetDataPresent returns "true".
Dim unicodeData() As Byte = Nothing
If dataObject.GetDataPresent(DataFormats.UnicodeText) Then
    unicodeData = TryCast(dataObject.GetData(DataFormats.UnicodeText), Byte())
End If

설명

호출 GetDataPresent 하여 호출 GetData하기 전에 이 데이터 개체에서 형식을 사용할 수 있는지 여부를 확인합니다. 이 데이터 개체에서 사용할 수 있는 모든 형식의 목록을 가져오려면 호출 GetFormats 합니다.

추가 정보

적용 대상

GetDataPresent(Type)

개체에서 지정 Type 한 형식으로 데이터를 사용할 수 있는지 또는 변환할 수 있는지 여부를 결정합니다.

public:
 virtual bool GetDataPresent(Type ^ format);
public bool GetDataPresent(Type format);
abstract member GetDataPresent : Type -> bool
override this.GetDataPresent : Type -> bool
Public Function GetDataPresent (format As Type) As Boolean

매개 변수

format
Type

확인할 데이터 형식을 지정하는 A Type 입니다. F 또는 미리 정의된 데이터 형식 집합은 클래스를 DataFormats 참조하세요.

반품

true데이터가 지정된 형식에 있거나 변환될 수 있으면 입니다. 그렇지 않으면 . false

구현

예외

formatnull입니다.

예제

다음 예제에서는 이 메서드를 사용하여 형식별 특정 데이터 형식의 존재를 쿼리합니다.

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

// Query for the presence of String data in the data object, by type.  In this overload 
// of GetDataPresent, the method will return true both for native data formats
// and when the data can automatically be converted to the specifed format.

// In this case, the Text data present in the data object can be autoconverted
// to type string (also represented by DataFormats.String), so GetDataPresent returns "true".
string stringData = null;
if (dataObject.GetDataPresent(typeof(string)))
{
    stringData = dataObject.GetData(DataFormats.Text) as string;
}
Dim dataObject As New DataObject("Some string data to store...")

' Query for the presence of String data in the data object, by type.  In this overload 
' of GetDataPresent, the method will return true both for native data formats
' and when the data can automatically be converted to the specifed format.

' In this case, the Text data present in the data object can be autoconverted
' to type string (also represented by DataFormats.String), so GetDataPresent returns "true".
Dim stringData As String = Nothing
If dataObject.GetDataPresent(GetType(String)) Then
    stringData = TryCast(dataObject.GetData(DataFormats.Text), String)
End If

설명

호출 GetDataPresent 하여 호출 GetData하기 전에 이 데이터 개체에서 형식을 사용할 수 있는지 여부를 확인합니다. 이 데이터 개체에서 사용할 수 있는 모든 형식의 목록을 가져오려면 호출 GetFormats 합니다.

추가 정보

적용 대상

GetDataPresent(String, Boolean)

지정된 형식으로 데이터를 사용할 수 있는지 또는 변환할 수 있는지 여부를 결정합니다. 플래그는 Boolean 데이터를 해당 형식으로 사용할 수 없는 경우 지정된 형식으로 변환할 수 있는지 여부를 나타냅니다.

public:
 virtual bool GetDataPresent(System::String ^ format, bool autoConvert);
public bool GetDataPresent(string format, bool autoConvert);
abstract member GetDataPresent : string * bool -> bool
override this.GetDataPresent : string * bool -> bool
Public Function GetDataPresent (format As String, autoConvert As Boolean) As Boolean

매개 변수

format
String

확인할 데이터 형식을 지정하는 문자열입니다. 미리 정의된 데이터 형식 집합은 클래스를 DataFormats 참조하세요.

autoConvert
Boolean

지정된 형식에 대해서만 확인하려면 또한 이 데이터 개체에 저장된 데이터를 지정된 형식으로 변환할 수 있는지 여부를 확인합니다.

반품

true데이터가 지정된 형식에 있거나 변환될 수 있으면 입니다. 그렇지 않으면 . false

구현

예외

formatnull입니다.

예제

다음 예제에서는 이 메서드를 사용하여 설명자 문자열로 데이터를 쿼리하고 자동 변환 가능한 데이터 형식을 처리하는 방법을 지정합니다.

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

// Query for the presence of Text data in the data object, by data format descriptor string,
// and specifying whether auto-convertible data formats are acceptable.  

// In this case, Text data is present natively, so GetDataPresent returns "true".
string textData = null;
if (dataObject.GetDataPresent(DataFormats.Text, false /* Auto-convert? */))
{
    textData = dataObject.GetData(DataFormats.Text) as string;
}

// In this case, the Text data in the data object can be autoconverted to 
// Unicode text, but it is not available natively, so GetDataPresent returns "false".
byte[] unicodeData = null;
if (dataObject.GetDataPresent(DataFormats.UnicodeText, false /* Auto-convert? */))
{
    unicodeData = dataObject.GetData(DataFormats.UnicodeText) as byte[];
}

// In this case, the Text data in the data object can be autoconverted to 
// Unicode text, so GetDataPresent returns "true".
if (dataObject.GetDataPresent(DataFormats.UnicodeText, true /* Auto-convert? */))
{
    unicodeData = dataObject.GetData(DataFormats.UnicodeText) as byte[];
}
Dim dataObject As New DataObject("Some string data to store...")

' Query for the presence of Text data in the data object, by data format descriptor string,
' and specifying whether auto-convertible data formats are acceptable.  

' In this case, Text data is present natively, so GetDataPresent returns "true".
Dim textData As String = Nothing
If dataObject.GetDataPresent(DataFormats.Text, False) Then ' Auto-convert? 
    textData = TryCast(dataObject.GetData(DataFormats.Text), String)
End If

' In this case, the Text data in the data object can be autoconverted to 
' Unicode text, but it is not available natively, so GetDataPresent returns "false".
Dim unicodeData() As Byte = Nothing
If dataObject.GetDataPresent(DataFormats.UnicodeText, False) Then ' Auto-convert? 
    unicodeData = TryCast(dataObject.GetData(DataFormats.UnicodeText), Byte())
End If

' In this case, the Text data in the data object can be autoconverted to 
' Unicode text, so GetDataPresent returns "true".
If dataObject.GetDataPresent(DataFormats.UnicodeText, True) Then ' Auto-convert? 
    unicodeData = TryCast(dataObject.GetData(DataFormats.UnicodeText), Byte())
End If

설명

호출 GetDataPresent 하여 호출 GetData하기 전에 이 데이터 개체에서 형식을 사용할 수 있는지 여부를 확인합니다. 이 데이터 개체에서 사용할 수 있는 모든 형식의 목록을 가져오려면 호출 GetFormats 합니다.

추가 정보

적용 대상