DataFormats 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
미리 정의된 static 형식 이름을 제공합니다Clipboard. 이를 사용하여 에 저장하는 데이터의 형식을 식별합니다 IDataObject.
public ref class DataFormats
public ref class DataFormats abstract sealed
public class DataFormats
public static class DataFormats
type DataFormats = class
Public Class DataFormats
- 상속
-
DataFormats
예제
다음 코드 예제에서는 새 myFormat데이터 형식을 만듭니다. 그런 다음 코드는 에 저장MyNewObject되는 값을 만듭니다DataObject. 에 DataObject 복사됩니다 Clipboard.
다음으로, DataObject 해당 위치에서 Clipboard 검색되고 MyNewObject 복구됩니다. 텍스트 MyNewObject 상자에 값이 인쇄됩니다. 이 코드를 사용하려면 폼을 만들고 배치해야 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
설명
또한 클래스 IDataObject 는 DataObject 형식 목록을 사용하여 static 시스템에서 Clipboard검색되거나 끌어서 놓기 작업에서 전송되는 데이터 형식을 결정합니다.
이 GetFormat 메서드를 사용하면 다음을 수행할 수 있습니다.
형식 이름 또는 ID 번호에 대해 미리 정의된 DataFormats.Format 개체를 가져옵니다.
이 클래스의
static목록에 새 형식 이름/ID 번호 쌍을 추가하고 형식 이름을 전달할 때 Windows 레지스트리에 Clipboard 형식으로 형식을 등록합니다.
인스턴스의 Id 적절한 속성에서 숫자 또는 형식 Name 을 DataFormats.Format 가져올 수 있습니다.
필드
| Name | Description |
|---|---|
| Bitmap |
Windows 비트맵 형식을 지정합니다. 이 |
| CommaSeparatedValue |
스프레드시트에서 사용되는 일반적인 교환 형식인 CSV(쉼표로 구분된 값) 형식을 지정합니다. 이 형식은 Windows Forms 직접 사용되지 않습니다. 이 |
| Dib |
Windows DIB(디바이스 독립적 비트맵) 형식을 지정합니다. 이 |
| Dif |
Windows Forms 직접 사용하지 않는 Windows DIF(데이터 교환 형식)를 지정합니다. 이 |
| EnhancedMetafile |
Windows 향상된 메타파일 형식을 지정합니다. 이 |
| FileDrop |
Windows Forms 직접 사용하지 않는 Windows 파일 삭제 형식을 지정합니다. 이 |
| Html |
HTML 클립보드 형식의 텍스트를 지정합니다. 이 |
| Locale |
Windows Forms 직접 사용하지 않는 Windows 문화권 형식을 지정합니다. 이 |
| MetafilePict |
Windows Forms 직접 사용하지 않는 Windows 메타파일 형식을 지정합니다. 이 |
| OemText |
표준 Windows OEM(원본 장비 제조업체) 텍스트 형식을 지정합니다. 이 |
| Palette |
Windows 색상표 형식을 지정합니다. 이 |
| PenData |
필기 소프트웨어에 대한 펜 스트로크로 구성된 Windows 펜 데이터 형식을 지정합니다. Windows Forms 이 형식을 사용하지 않습니다. 이 |
| Riff |
Windows Forms 직접 사용하지 않는 RIFF(리소스 교환 파일 형식) 오디오 형식을 지정합니다. 이 |
| Rtf |
RTF(서식 있는 텍스트 형식) 데이터로 구성된 텍스트를 지정합니다. 이 |
| Serializable |
모든 형식의 Windows Forms 개체를 캡슐화하는 형식을 지정합니다. 이 |
| StringFormat |
Windows Forms 문자열 개체를 저장하는 데 사용하는 Windows Forms 문자열 클래스 형식을 지정합니다. 이 |
| SymbolicLink |
Windows Forms 직접 사용하지 않는 Windows 기호 링크 형식을 지정합니다. 이 |
| Text |
표준 ANSI 텍스트 형식을 지정합니다. 이 |
| Tiff |
Windows Forms 직접 사용하지 않는 TIFF(태그가 지정된 이미지 파일 형식)를 지정합니다. 이 |
| UnicodeText |
표준 Windows 유니코드 텍스트 형식을 지정합니다. 이 |
| WaveAudio |
Windows Forms 직접 사용하지 않는 웨이브 오디오 형식을 지정합니다. 이 |
메서드
| Name | Description |
|---|---|
| GetFormat(Int32) |
Windows 클립보드 숫자 ID와 지정된 ID의 이름을 사용하여 DataFormats.Format 반환합니다. |
| GetFormat(String) |
Windows 클립보드 숫자 ID와 지정된 형식의 이름을 사용하여 DataFormats.Format 반환합니다. |