DataFormats Sınıf
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.
staticönceden tanımlanmış Clipboard biçim adları sağlar. Bir içinde IDataObjectdepoladığınız veri biçimini tanımlamak için bunları kullanın.
public ref class DataFormats
public ref class DataFormats abstract sealed
public class DataFormats
public static class DataFormats
type DataFormats = class
Public Class DataFormats
- Devralma
-
DataFormats
Örnekler
Aşağıdaki kod örneği adlı myFormatyeni bir veri biçimi oluşturur. Kod daha sonra içinde MyNewObject depoladığı bir DataObjectoluşturur.
DataObject, öğesine Clipboardkopyalanır.
Ardından, DataObject öğesini ve ClipboardMyNewObject kurtarılır. değeri MyNewObject bir metin kutusuna yazdırılır. Bu kod, bir forma oluşturulup yerleştirilmesini gerektirir textBox1 .
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Windows::Forms;
// Creates a new type.
[Serializable]
public ref class MyNewObject: public Object
{
private:
String^ myValue;
public:
// Creates a default constructor for the class.
MyNewObject()
{
myValue = "This is the value of the class";
}
property String^ MyObjectValue
{
// Creates a property to retrieve or set the value.
String^ get()
{
return myValue;
}
void set( String^ value )
{
myValue = value;
}
}
};
public ref class MyClass: public Form
{
protected:
TextBox^ textBox1;
public:
void MyClipboardMethod()
{
// Creates a new data format.
DataFormats::Format^ myFormat = DataFormats::GetFormat( "myFormat" );
/* Creates a new object and stores it in a DataObject using myFormat
* as the type of format. */
MyNewObject^ myObject = gcnew MyNewObject;
DataObject^ myDataObject = gcnew DataObject( myFormat->Name,myObject );
// Copies myObject into the clipboard.
Clipboard::SetDataObject( myDataObject );
// Performs some processing steps.
// Retrieves the data from the clipboard.
IDataObject^ myRetrievedObject = Clipboard::GetDataObject();
// Converts the IDataObject type to MyNewObject type.
MyNewObject^ myDereferencedObject = dynamic_cast<MyNewObject^>(myRetrievedObject->GetData( myFormat->Name ));
// Prints the value of the Object in a textBox.
textBox1->Text = myDereferencedObject->MyObjectValue;
}
};
using System;
using System.Windows.Forms;
public class MyClass : Form {
protected TextBox textBox1;
public void MyClipboardMethod() {
// Creates a new data format.
DataFormats.Format myFormat = DataFormats.GetFormat("myFormat");
/* Creates a new object and stores it in a DataObject using myFormat
* as the type of format. */
MyNewObject myObject = new MyNewObject();
DataObject myDataObject = new DataObject(myFormat.Name, myObject);
// Copies myObject into the clipboard.
Clipboard.SetDataObject(myDataObject);
// Performs some processing steps.
// Retrieves the data from the clipboard.
IDataObject myRetrievedObject = Clipboard.GetDataObject();
// Converts the IDataObject type to MyNewObject type.
MyNewObject myDereferencedObject = (MyNewObject)myRetrievedObject.GetData(myFormat.Name);
// Prints the value of the Object in a textBox.
textBox1.Text = myDereferencedObject.MyObjectValue;
}
}
// Creates a new type.
[Serializable]
public class MyNewObject : Object {
private string myValue;
// Creates a default constructor for the class.
public MyNewObject() {
myValue = "This is the value of the class";
}
// Creates a property to retrieve or set the value.
public string MyObjectValue {
get {
return myValue;
}
set {
myValue = value;
}
}
}
Option Explicit
Option Strict
Imports System.Windows.Forms
Public Class MyClass1
Inherits Form
Private textBox1 As TextBox
Public Sub MyClipboardMethod()
' Creates a new data format.
Dim myFormat As DataFormats.Format = _
DataFormats.GetFormat("myFormat")
' Creates a new object and store it in a DataObject using myFormat
' as the type of format.
Dim myObject As New MyNewObject()
Dim myDataObject As New DataObject(myFormat.Name, myObject)
' Copies myObject into the clipboard.
Clipboard.SetDataObject(myDataObject)
' Performs some processing steps.
' Retrieves the data from the clipboard.
Dim myRetrievedObject As IDataObject = Clipboard.GetDataObject()
' Converts the IDataObject type to MyNewObject type.
Dim myDereferencedObject As MyNewObject = _
CType(myRetrievedObject.GetData(myFormat.Name), MyNewObject)
' Print the value of the Object in a textBox.
textBox1.Text = myDereferencedObject.MyObjectValue
End Sub
End Class
' Creates a new type.
<Serializable()> Public Class MyNewObject
Inherits Object
Private myValue As String
' Creates a default constructor for the class.
Public Sub New()
myValue = "This is the value of the class"
End Sub
' Creates a property to retrieve or set the value.
Public Property MyObjectValue() As String
Get
Return myValue
End Get
Set
myValue = value
End Set
End Property
End Class
Açıklamalar
IDataObject ve DataObject sınıfları, sistemden staticalınan veya sürükle ve bırak işleminde aktarılan veri türünü belirlemek için biçim listesini de kullanırClipboard.
GetFormat yöntemi şunları yapmanızı sağlar:
Biçim adı veya kimlik numarası için önceden tanımlanmış DataFormats.Format bir nesne alın.
Bu sınıftaki
staticlistesine yeni bir biçim adı/kimlik numarası çifti ekleyin ve biçim adını geçirirken biçimi Windows kayıt defterine Clipboard biçimi olarak kaydedin.
Örneğin uygun Id özelliğinden Name sayıyı veya biçimi DataFormats.Format alabilirsiniz.
Alanlar
| Name | Description |
|---|---|
| Bitmap |
Windows bit eşlem biçimini belirtir. Bu |
| CommaSeparatedValue |
Elektronik tablolar tarafından kullanılan ortak bir değişim biçimi olan virgülle ayrılmış değer (CSV) biçimini belirtir. Bu biçim doğrudan Windows Forms tarafından kullanılmaz. Bu |
| Dib |
Cihazdan bağımsız bit eşlem (DIB) biçimini Windows belirtir. Bu |
| Dif |
Windows Forms doğrudan kullanmadığı Windows Veri Değişim Biçimini (DIF) belirtir. Bu |
| EnhancedMetafile |
gelişmiş Windows meta dosyası biçimini belirtir. Bu |
| FileDrop |
Windows Forms doğrudan kullanmadığı Windows dosya bırakma biçimini belirtir. Bu |
| Html |
HTML Panosu biçimindeki metni belirtir. Bu |
| Locale |
Windows Forms doğrudan kullanmadığı Windows kültür biçimini belirtir. Bu |
| MetafilePict |
Windows Forms doğrudan kullanmadığı Windows meta dosyası biçimini belirtir. Bu |
| OemText |
Standart Windows özgün donanım üreticisi (OEM) metin biçimini belirtir. Bu |
| Palette |
Windows palet biçimini belirtir. Bu |
| PenData |
El yazısı yazılımı için kalem vuruşlarından oluşan Windows kalem veri biçimini belirtir; Windows Forms bu biçimi kullanmaz. Bu |
| Riff |
Kaynak Değişim Dosyası Biçimi (RIFF) ses biçimini belirtir ve Windows Forms doğrudan kullanmaz. Bu |
| Rtf |
Zengin Metin Biçimi (RTF) verilerinden oluşan metni belirtir. Bu |
| Serializable |
Her tür Windows Forms nesnesini kapsülleyen bir biçim belirtir. Bu |
| StringFormat |
Windows Forms dize nesnelerini depolamak için kullandığı Windows Forms dize sınıfı biçimini belirtir. Bu |
| SymbolicLink |
Windows Forms doğrudan kullanmadığı Windows sembolik bağlantı biçimini belirtir. Bu |
| Text |
Standart ANSI metin biçimini belirtir. Bu |
| Tiff |
Windows Forms doğrudan kullanmadığı Etiketli Görüntü Dosyası Biçimini (TIFF) belirtir. Bu |
| UnicodeText |
Standart Windows Unicode metin biçimini belirtir. Bu |
| WaveAudio |
Windows Forms doğrudan kullanmadığı dalga ses biçimini belirtir. Bu |
Yöntemler
| Name | Description |
|---|---|
| GetFormat(Int32) |
Belirtilen kimliğin Windows Pano sayısal kimliği ve adıyla bir DataFormats.Format döndürür. |
| GetFormat(String) |
Belirtilen biçim için Windows Pano sayısal kimliği ve adıyla bir DataFormats.Format döndürür. |