DataObject.GetDataPresent Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Burada DataObject depolanan verilerin belirtilen biçimle ilişkili olup olmadığını belirler.
Aşırı Yüklemeler
| Name | Description |
|---|---|
| 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şkilendirilip ilişkilendirilmeyeceğini veya bu biçime dönüştürülebileceğini belirler. |
| GetDataPresent(Type) |
Bu DataObject dosyada depolanan verilerin belirtilen biçimle ilişkilendirilip ilişkilendirilmeyeceğini veya bu biçime dönüştürülebileceğini belirler. |
GetDataPresent(String, Boolean)
- Kaynak:
- DataObject.cs
- Kaynak:
- DataObject.cs
- Kaynak:
- DataObject.cs
- Kaynak:
- DataObject.cs
- Kaynak:
- DataObject.cs
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 dönüştürülebilirse; 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 autoConvertbelirterek false 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 autoConvertbelirterek true dize biçimiyle ilişkili veriler için sorgulanır. Sonuçlar metin kutusuna yazdırılır. Bu kod 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ğrısı yapılmadan önce bir biçimin mevcut olup olmadığını belirlemek için bu yöntemi çağırabilirsiniz GetData. Bu GetFormatsiçinde kullanılabilen biçimleri çağırınDataObject.
Bu yöntem aşağıdaki durumlarda döndürür true :
autoConvertparametresidirtrueve veriler uygun biçime dönüştürülebilen bir biçimdedir.autoConvertparametresidirfalseve veriler uygun biçimdedir.
Bu yöntem aşağıdaki durumlarda döndürür false :
autoConvertparametresidirtrueve bu yöntem verileri belirtilen biçimde bulamıyor ve verileri belirtilen biçime dönüştüremiyor veya otomatik dönüştürme olarak ayarlanmışfalseolarak depolandı.autoConvertparametresidirfalseve veriler belirtilen biçimde mevcut DataObject değildir.
Note
Veriler, dönüştürmeye izin verilip verilmediğini belirterek depolandıysa 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.
Note
Hiçbir veri alınamıyorsa, hiçbir özel durum oluşturulmayacak. Bunun yerine döndürülür false .
Ayrıca bkz.
Şunlara uygulanır
GetDataPresent(String)
- Kaynak:
- DataObject.cs
- Kaynak:
- DataObject.cs
- Kaynak:
- DataObject.cs
- Kaynak:
- DataObject.cs
- Kaynak:
- DataObject.cs
Bu DataObject dosyada depolanan verilerin belirtilen biçimle ilişkilendirilip ilişkilendirilmeyeceğini 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şkilendirilip ilişkilendirilmeyeceğini 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.
Daha sonra, örneklerde metin verilerinin DataObjectiçinde bulunup bulunmadığı yazdırılır. Bu kod oluşturulmasını gerektirir textBox1 .
Açıklamalar
çağrısı yapılmadan önce bir biçimin mevcut olup olmadığını belirlemek için bu yöntemi çağırabilirsiniz GetData. Bu GetFormatsiçinde kullanılabilen biçimleri çağırınDataObject.
Note
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.
Note
Hiçbir veri alınamıyorsa, hiçbir özel durum oluşturulmayacak. Bunun yerine döndürülür false .
Ayrıca bkz.
Şunlara uygulanır
GetDataPresent(Type)
- Kaynak:
- DataObject.cs
- Kaynak:
- DataObject.cs
- Kaynak:
- DataObject.cs
- Kaynak:
- DataObject.cs
- Kaynak:
- DataObject.cs
Bu DataObject dosyada depolanan verilerin belirtilen biçimle ilişkilendirilip ilişkilendirilmeyeceğini 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
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. Kodun textBox1 oluşturulması gerekir.
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ğrısı yapılmadan önce bir biçimin mevcut olup olmadığını belirlemek için bu yöntemi çağırabilirsiniz GetData. Bu GetFormatsiçinde kullanılabilen biçimleri çağırınDataObject.
Note
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.
Note
Hiçbir veri alınamıyorsa, hiçbir özel durum oluşturulmayacak. Bunun yerine döndürülür false .