DataObject.GetDataPresent Yöntem

Tanım

Bu DataObject dosyada depolanan verilerin belirtilen biçimle ilişkili olup olmadığını belirler.

Aşırı Yüklemeler

GetDataPresent(String)

Bu DataObject dosyada depolanan verilerin belirtilen biçimle ilişkili olup olmadığını veya bu biçime dönüştürülebileceğini belirler.

GetDataPresent(Type)

Bu DataObject dosyada depolanan verilerin belirtilen biçimle ilişkili olup olmadığını veya bu biçime dönüştürülebileceğini belirler.

GetDataPresent(String, Boolean)

Bunun DataObject belirtilen biçimde veri içerip içermediğini veya isteğe bağlı olarak, belirtilen biçime dönüştürülebilecek verileri içerip içermediğini belirler.

GetDataPresent(String)

Bu DataObject dosyada depolanan verilerin belirtilen biçimle ilişkili olup olmadığını veya bu biçime dönüştürülebileceğini belirler.

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

Parametreler

format
String

Denetlenecek biçim. Önceden tanımlanmış biçimler için bkz DataFormats .

Döndürülenler

true bu DataObject dosyada depolanan veriler ile ilişkilendirilmişse veya bu biçime dönüştürülebiliyorsa, belirtilen biçime; aksi takdirde, false.

Uygulamalar

Örnekler

Aşağıdaki kod örneği, şu anda bu DataObject dosyada depolanan verilerin belirtilen biçimle ilişkili olup olmadığını veya bu biçime dönüştürülebileceğini belirler. Yeni DataObject bir dize ve metin olarak belirtilen ilişkili biçimiyle başlatılır.

Ardından, örneklerde metin verilerinin içinde DataObjectbulunup bulunmadığı yazdırılır. Bu kod, bunun oluşturulmasını gerektirir textBox1 .

Açıklamalar

çağırmadan önce bir biçimin mevcut olup olmadığını belirlemek için bu yöntemi çağırabilirsiniz GetData. Bu DataObjectiçinde kullanılabilen biçimleri çağırınGetFormats.

Not

Veriler, dönüştürmeye izin verileceğini belirterek depolanmışsa ve istenen biçim depolanmış biçimle uyumluysa başka bir biçime dönüştürülebilir. Örneğin, Unicode olarak depolanan veriler metne dönüştürülebilir.

Not

Veri alınamıyorsa özel durum oluşturulmayacak. Bunun yerine döndürülür false .

Ayrıca bkz.

Şunlara uygulanır

GetDataPresent(Type)

Bu DataObject dosyada depolanan verilerin belirtilen biçimle ilişkili olup olmadığını veya bu biçime dönüştürülebileceğini belirler.

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

Parametreler

format
Type

Type Denetlenecek biçimi temsil eden bir.

Döndürülenler

true bu DataObject dosyada depolanan veriler ile ilişkilendirilmişse veya bu biçime dönüştürülebiliyorsa, belirtilen biçime; aksi takdirde, false.

Uygulamalar

Örnekler

Aşağıdaki kod örneği, belirtilen türdeki verilerin bir DataObjectiçinde var olup olmadığını veya verilerin belirtilen türe dönüştürülip dönüştürülemeyeceğini belirler. Sonuç bir metin kutusunda görüntülenir. Kod, bunun oluşturulmasını gerektirir 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

Açıklamalar

çağırmadan önce bir biçimin mevcut olup olmadığını belirlemek için bu yöntemi çağırabilirsiniz GetData. Bu DataObjectiçinde kullanılabilen biçimleri çağırınGetFormats.

Not

Veriler, dönüştürmeye izin verileceğini belirterek depolanmışsa ve istenen biçim depolanmış biçimle uyumluysa başka bir biçime dönüştürülebilir. Örneğin, Unicode olarak depolanan veriler metne dönüştürülebilir.

Not

Veri alınamıyorsa özel durum oluşturulmayacak. Bunun yerine döndürülür false .

Ayrıca bkz.

Şunlara uygulanır

GetDataPresent(String, Boolean)

Bunun DataObject belirtilen biçimde veri içerip içermediğini veya isteğe bağlı olarak, belirtilen biçime dönüştürülebilecek verileri içerip içermediğini belirler.

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

Parametreler

format
String

Denetlenecek biçim. Önceden tanımlanmış biçimler için bkz DataFormats .

autoConvert
Boolean

true bu dosyada DataObject depolanan verilerin belirtilen biçime dönüştürülip dönüştürülemeyeceğini belirlemek; verilerin belirtilen biçimde false olup olmadığını denetlemek için.

Döndürülenler

true veriler belirtilen biçimdeyse veya bu biçime dönüştürülebiliyorsa; aksi takdirde , false.

Uygulamalar

Örnekler

Aşağıdaki kod örneği, şu anda içinde DataObject depolanan verilerin belirtilen bir biçimle ilişkili olup olmadığını belirler. İlk olarak, yeni DataObject bir dize ile başlatılır ve biçimini metin olarak belirtir.

DataObject Ardından, parametresi olarak falsebelirterek autoConvert metin biçimiyle ilişkili veriler için sorgulanır. Bu sorgunun sonucu bir metin kutusuna yazdırılır.

DataObject Ardından, parametresi olarak truebelirterek autoConvert dize biçimiyle ilişkili veriler için sorgulanır. Sonuçlar metin kutusuna yazdırılır. Bu kod, bunun oluşturulmasını gerektirir 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

Açıklamalar

çağırmadan önce bir biçimin mevcut olup olmadığını belirlemek için bu yöntemi çağırabilirsiniz GetData. Bu DataObjectiçinde kullanılabilen biçimleri çağırınGetFormats.

Bu yöntem şu durumlarda döndürür true :

  • autoConvert parametresidir true ve veriler uygun biçime dönüştürülebilecek bir biçimdedir.

  • autoConvert parametresidir false ve veriler uygun biçimdedir.

Bu yöntem şu durumlarda döndürür false :

  • autoConvert parametresidir true ve bu yöntem belirtilen biçimdeki verileri bulamıyor ve verileri belirtilen biçime dönüştüremiyor veya veriler olarak ayarlanmış falseotomatik dönüştürme ile depolandı.

  • autoConvert parametresidir false ve veriler belirtilen biçimde mevcut DataObject değildir.

Not

Veriler, dönüştürmeye izin verileceğini belirterek depolanmışsa ve istenen biçim depolanmış biçimle uyumluysa başka bir biçime dönüştürülebilir. Örneğin, Unicode olarak depolanan veriler metne dönüştürülebilir.

Not

Veri alınamıyorsa özel durum oluşturulmayacak. Bunun yerine döndürülür false .

Ayrıca bkz.

Şunlara uygulanır