DataObject.GetDataPresent 메서드

정의

DataObject에 저장된 데이터가 지정된 형식과 연결되어 있는지 여부를 확인합니다.

오버로드

GetDataPresent(String)

DataObject에 저장된 데이터가 지정된 형식과 연결되어 있거나 지정된 형식으로 변환될 수 있는지 여부를 확인합니다.

GetDataPresent(Type)

DataObject에 저장된 데이터가 지정된 형식과 연결되어 있거나 지정된 형식으로 변환될 수 있는지 여부를 확인합니다.

GetDataPresent(String, Boolean)

DataObject에 지정된 형식의 데이터가 포함되어 있는지 여부를 확인하고 지정된 형식으로 변환될 수 있는 데이터가 포함되어 있는지 여부를 선택적으로 확인합니다.

GetDataPresent(String)

DataObject에 저장된 데이터가 지정된 형식과 연결되어 있거나 지정된 형식으로 변환될 수 있는지 여부를 확인합니다.

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

매개 변수

format
String

확인할 형식입니다. 미리 정의된 형식에 대한 자세한 내용은 DataFormats를 참조하십시오.

반환

Boolean

DataObject에 저장된 데이터가 지정된 형식과 연결되어 있거나 지정된 형식으로 변환될 수 있으면 true이고, 그렇지 않으면 false입니다.

구현

예제

다음 코드 예제에서는 현재 이 DataObject 값에 저장된 데이터가 지정된 형식과 연결되어 있는지 또는 지정된 형식으로 변환될 수 있는지를 결정합니다. 문자열 및 텍스트로 지정된 연결된 형식으로 새 DataObject 형식이 초기화됩니다.

그런 다음, 텍스트 데이터가 에 있는지 여부를 출력합니다 DataObject. 이 코드를 실행 하려면 textBox1 만들었습니다.

설명

호출하기 전에 형식이 있는지 여부를 확인하려면 이 메서드를 호출 GetData합니다. 이 DataObject형식에서 사용할 수 있는 형식을 호출 GetFormats 합니다.

참고

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

참고

데이터를 검색할 수 없는 경우 예외가 throw되지 않습니다. 대신, false 반환됩니다.

추가 정보

적용 대상

GetDataPresent(Type)

DataObject에 저장된 데이터가 지정된 형식과 연결되어 있거나 지정된 형식으로 변환될 수 있는지 여부를 확인합니다.

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

매개 변수

format
Type

확인할 형식을 나타내는 Type입니다.

반환

Boolean

DataObject에 저장된 데이터가 지정된 형식과 연결되어 있거나 지정된 형식으로 변환될 수 있으면 true이고, 그렇지 않으면 false입니다.

구현

예제

다음 코드 예제에서는 지정된 형식의 데이터가 있는지 또는 데이터를 지정된 형식 DataObject으로 변환할 수 있는지 여부를 결정합니다. 결과 텍스트 상자에 표시 됩니다. 코드를 만들려면 코드가 textBox1 필요합니다.

private:
   void GetIfPresent2()
   {
      // Creates a component to store in the data object.
      Component^ myComponent = gcnew Component;
      
      // Creates a new data object and assigns it the component.
      DataObject^ myDataObject = gcnew DataObject( myComponent );
      
      // Creates a type to store the type of data.
      Type^ myType = myComponent->GetType();
      
      // Determines if the DataObject has data of the Type format.
      textBox1->Text = String::Concat( "Is the specified data type available ",
         "in the DataObject? ", myDataObject->GetDataPresent( myType ), "\n" );
      
      // Retrieves the data using its type format, and displays the type.
      Object^ myObject = myDataObject->GetData( myType );
      textBox1->Text = String::Concat( textBox1->Text, "The data type stored ",
         "in the DataObject is: ", myObject->GetType()->Name );
   }
private void GetIfPresent2() {
    // Creates a component to store in the data object.
    Component myComponent = new Component();
 
    // Creates a new data object and assigns it the component.
    DataObject myDataObject = new DataObject(myComponent);
 
    // Creates a type to store the type of data.
    Type myType = myComponent.GetType();
 
    // Determines if the DataObject has data of the Type format.
    textBox1.Text = "Is the specified data type available in the " +
       "DataObject? " + myDataObject.GetDataPresent(myType).ToString() + '\n';
 
    // Retrieves the data using its type format, and displays the type.
    Object myObject = myDataObject.GetData(myType);
    textBox1.Text += "The data type stored in the DataObject is: " +
       myObject.GetType().Name;
 }
Private Sub GetIfPresent2()
    ' Creates a component to store in the data object.
    Dim myComponent As New Component()
    
    ' Creates a new data object and assigns it the component.
    Dim myDataObject As New DataObject(myComponent)
    
    ' Creates a type to store the type of data.
    Dim myType As Type = myComponent.GetType()
    
    ' Determines if the DataObject has data of the Type format.
    textBox1.Text = "Is the specified data type available in the " & "DataObject? " & _
        myDataObject.GetDataPresent(myType).ToString() & ControlChars.Cr
    
    ' Retrieves the data using its type format, and displays the type.
    Dim myObject As Object = myDataObject.GetData(myType)
    textBox1.Text += "The data type stored in the DataObject is: " + myObject.GetType().Name
End Sub

설명

호출하기 전에 형식이 있는지 여부를 확인하려면 이 메서드를 호출 GetData합니다. 이 DataObject형식에서 사용할 수 있는 형식을 호출 GetFormats 합니다.

참고

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

참고

데이터를 검색할 수 없는 경우 예외가 throw되지 않습니다. 대신, false 반환됩니다.

추가 정보

적용 대상

GetDataPresent(String, Boolean)

DataObject에 지정된 형식의 데이터가 포함되어 있는지 여부를 확인하고 지정된 형식으로 변환될 수 있는 데이터가 포함되어 있는지 여부를 선택적으로 확인합니다.

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

매개 변수

format
String

확인할 형식입니다. 미리 정의된 형식에 대한 자세한 내용은 DataFormats를 참조하십시오.

autoConvert
Boolean

DataObject에 저장된 데이터를 지정된 형식으로 변환할 수 있는지 여부를 확인하려면 true이고, 데이터 형식이 지정된 형식인지 여부를 확인하려면 false입니다.

반환

Boolean

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

구현

예제

다음 코드 예제에서는 현재 저장된 DataObject 데이터가 지정된 형식과 연결되어 있는지 여부를 확인합니다. 첫째, 새 DataObject 형식을 텍스트로 지정하여 문자열로 초기화합니다.

DataObject 그런 다음, 매개 변수를 로 false지정하여 autoConvert 텍스트 형식과 연결된 데이터에 대해 쿼리합니다. 이 쿼리의 결과는 텍스트 상자에 인쇄됩니다.

DataObject 그런 다음, 매개 변수를 .로 true지정하여 autoConvert 문자열 형식과 연결된 데이터에 대해 쿼리합니다. 결과는 텍스트 상자에 인쇄됩니다. 이 코드를 실행 하려면 textBox1 만들었습니다.

private:
   void GetIfPresent3()
   {
      // Creates a new data object using a string and the text format.
      DataObject^ myDataObject = gcnew DataObject( DataFormats::Text, "Another string" );
      
      // Prints the string in a text box with autoconvert = false.
      if ( myDataObject->GetDataPresent( "System.String", false ) )
      {
         // Prints the string in a text box.
         textBox1->Text = String::Concat(
            myDataObject->GetData( "System.String", false )->ToString(), "\n" );
      }
      else
      {
         textBox1->Text = "Could not convert data to specified format\n";
      }
      
      // Prints the string in a text box with autoconvert = true.
      textBox1->Text = String::Concat( textBox1->Text,
         "With autoconvert = true, you can convert text to string format. String is: ",
         myDataObject->GetData( "System.String", true )->ToString() );
   }
private void GetIfPresent3() {
    // Creates a new data object using a string and the text format.
    DataObject myDataObject = new DataObject(DataFormats.Text, "Another string");
 
    // Prints the string in a text box with autoconvert = false.
    if(myDataObject.GetDataPresent("System.String", false)) {
       // Prints the string in a text box.
       textBox1.Text = myDataObject.GetData("System.String", false).ToString() + '\n';
    } else
        {
            textBox1.Text = "Could not convert data to specified format" + '\n';
        }

        // Prints the string in a text box with autoconvert = true.
        textBox1.Text += "With autoconvert = true, you can convert text to string format. " +
       "String is: " + myDataObject.GetData("System.String", true).ToString();
 }
Private Sub GetIfPresent3()
    ' Creates a new data object using a string and the text format.
    Dim myDataObject As New DataObject(DataFormats.Text, "Another string")
    
    ' Prints the string in a text box with autoconvert = false.
    If myDataObject.GetDataPresent("System.String", False) Then
        ' Prints the string in a text box.
        textBox1.Text = myDataObject.GetData("System.String", False).ToString() & ControlChars.Cr
    Else
        textBox1.Text = "Could not convert data to specified format" & ControlChars.Cr
    End If 
    ' Prints the string in a text box with autoconvert = true.
    textBox1.Text &= "With autoconvert = true, you can convert text to string format. " & _
                    "String is: " & myDataObject.GetData("System.String", True).ToString()
End Sub

설명

호출하기 전에 형식이 있는지 여부를 확인하려면 이 메서드를 호출 GetData합니다. 이 DataObject형식에서 사용할 수 있는 형식을 호출 GetFormats 합니다.

이 메서드는 다음과 같은 경우를 반환합니다 true .

  • autoConvert 매개 변수가 true 있고 데이터는 적절한 형식으로 변환할 수 있는 형식입니다.

  • autoConvert 매개 변수가 false 있고 데이터가 적절한 형식입니다.

이 메서드는 다음과 같은 경우를 반환합니다 false .

  • autoConvert 매개 변수는 true 이 메서드가 지정된 형식의 데이터를 찾을 수 없으며 데이터를 지정된 형식으로 변환할 수 없거나 데이터가 자동 변환으로 설정된 상태로 false저장되었습니다.

  • autoConvert 매개 변수가 false 있고 데이터가 지정된 형식으로 존재하지 DataObject 않습니다.

참고

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

참고

데이터를 검색할 수 없는 경우 예외가 throw되지 않습니다. 대신, false 반환됩니다.

추가 정보

적용 대상