IDataObject.SetData 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 데이터 및 관련 형식을 이 인스턴스에 저장합니다.
오버로드
| Name | Description |
|---|---|
| SetData(Object) |
형식에 대한 데이터 클래스를 사용하여 지정된 데이터를 이 인스턴스에 저장합니다. |
| SetData(String, Object) |
지정된 데이터 및 관련 형식을 이 인스턴스에 저장합니다. |
| SetData(Type, Object) |
지정된 데이터 및 관련 클래스 형식을 이 인스턴스에 저장합니다. |
| SetData(String, Boolean, Object) |
부울 값을 사용하여 데이터를 다른 형식으로 변환할 수 있는지 여부를 지정하여 지정된 데이터 및 관련 형식을 이 인스턴스에 저장합니다. |
SetData(Object)
- Source:
- IDataObject.cs
- Source:
- IDataObject.cs
- Source:
- IDataObject.cs
- Source:
- IDataObject.cs
- Source:
- IDataObject.cs
형식에 대한 데이터 클래스를 사용하여 지정된 데이터를 이 인스턴스에 저장합니다.
public:
void SetData(System::Object ^ data);
public void SetData(object data);
public void SetData(object? data);
abstract member SetData : obj -> unit
Public Sub SetData (data As Object)
매개 변수
- data
- Object
저장할 데이터입니다.
예제
이 예제에서는 구현 하는 클래스를 DataObject사용 하 여 IDataObject 메서드의 사용을 보여 줍니다SetData. 먼저 구성 요소(myComponent)를 만들고 데이터 개체(myDataObject)에 저장합니다. 그런 다음 지정된 데이터가 데이터 개체에 저장되어 있는지 여부를 확인하고 결과를 메시지 상자에 표시합니다. 이 예제에서는 명명Form된 이름을 만들었다고 가정합니다Form1.
private:
void SetData1()
{
// Creates a component to store in the data object.
Component^ myComponent = gcnew Component;
// Creates a data object.
DataObject^ myDataObject = gcnew DataObject;
// Adds the component to the data object.
myDataObject->SetData( myComponent );
// Checks whether data of the specified type is in the data object.
Type^ myType = myComponent->GetType();
String^ myMessageText;
if ( myDataObject->GetDataPresent( myType ) )
{
myMessageText = "Data of type " + myType->Name +
" is present in the data object";
}
else
{
myMessageText = "Data of type " + myType->Name +
" is not present in the data object";
}
// Displays the result in a message box.
MessageBox::Show( myMessageText, "The Test Result" );
}
private void SetData1()
{
// Creates a component to store in the data object.
Component myComponent = new Component();
// Creates a data object.
DataObject myDataObject = new DataObject();
// Adds the component to the data object.
myDataObject.SetData(myComponent);
// Checks whether data of the specified type is in the data object.
Type myType = myComponent.GetType();
string myMessageText;
if(myDataObject.GetDataPresent(myType))
myMessageText = "Data of type " + myType.Name +
" is present in the data object";
else
myMessageText = "Data of type " + myType.Name +
" is not present in the data object";
// Displays the result in a message box.
MessageBox.Show(myMessageText, "The Test Result");
}
Private Sub SetData1()
' Creates a component to store in the data object.
Dim myComponent As New System.ComponentModel.Component()
' Creates a data object.
Dim myDataObject As New DataObject()
' Adds the component to the data object.
myDataObject.SetData(myComponent)
' Checks whether data of the specified type is in the data object.
Dim myType As Type = myComponent.GetType()
Dim myMessageText As String
If myDataObject.GetDataPresent(myType) Then
myMessageText = "Data of type " + myType.Name + " is present in the data object"
Else
myMessageText = "Data of type " + myType.Name + " is not present in the data object"
End If
' Displays the result in a message box.
MessageBox.Show(myMessageText, "The Test Result")
End Sub
설명
형식은 데이터 클래스에서 파생됩니다.
이 메서드를 사용하여 저장된 데이터를 검색할 때 호환되는 형식으로 변환할 수 있습니다.
이 메서드의 구현은 다음을 참조하세요 DataObject.SetData.
추가 정보
적용 대상
SetData(String, Object)
- Source:
- IDataObject.cs
- Source:
- IDataObject.cs
- Source:
- IDataObject.cs
- Source:
- IDataObject.cs
- Source:
- IDataObject.cs
지정된 데이터 및 관련 형식을 이 인스턴스에 저장합니다.
public:
void SetData(System::String ^ format, System::Object ^ data);
public void SetData(string format, object data);
public void SetData(string format, object? data);
abstract member SetData : string * obj -> unit
Public Sub SetData (format As String, data As Object)
매개 변수
- format
- String
데이터와 연결된 형식입니다. 미리 정의된 형식은 참조 DataFormats 하세요.
- data
- Object
저장할 데이터입니다.
예제
이 예제에서는 구현 하는 클래스를 DataObject사용 하 여 IDataObject 메서드의 사용을 보여 줍니다SetData. 먼저 데이터 개체(myDataObject)를 만들고 형식을 지정하는 개체에 문자열을 UnicodeText 저장합니다. 그런 다음 형식을 지정하는 개체에 저장된 데이터를 검색하여 Text 데이터가 형식으로 변환되도록 합니다 Text . 결과는 메시지 상자에 표시됩니다. 이 예제에서는 명명Form된 이름을 만들었다고 가정합니다Form1.
private:
void SetData2()
{
// Creates a data object.
DataObject^ myDataObject = gcnew DataObject;
// Stores a string, specifying the UnicodeText format.
myDataObject->SetData( DataFormats::UnicodeText, "Hello World!" );
// Retrieves the data by specifying the Text format.
String^ myMessageText = "The data type is " +
myDataObject->GetData( DataFormats::Text )->GetType()->Name;
// Displays the result.
MessageBox::Show( myMessageText, "The Test Result" );
}
private void SetData2()
{
// Creates a data object.
DataObject myDataObject = new DataObject();
// Stores a string, specifying the UnicodeText format.
myDataObject.SetData(DataFormats.UnicodeText, "Hello World!");
// Retrieves the data by specifying the Text format.
string myMessageText = "The data type is " + myDataObject.GetData(DataFormats.Text).GetType().Name;
// Displays the result.
MessageBox.Show(myMessageText, "The Test Result");
}
Private Sub SetData2()
' Creates a data object.
Dim myDataObject As New DataObject()
' Stores a string, specifying the UnicodeText format.
myDataObject.SetData(DataFormats.UnicodeText, "Hello World!")
' Retrieves the data by specifying the Text format.
Dim myMessageText As String = "The data type is " & _
myDataObject.GetData(DataFormats.Text).GetType().Name
' Displays the result.
MessageBox.Show(myMessageText, "The Test Result")
End Sub
설명
대상 애플리케이션의 형식을 모르는 경우 이 메서드를 사용하여 여러 형식으로 데이터를 저장할 수 있습니다.
이 메서드를 사용하여 저장된 데이터를 검색할 때 호환되는 형식으로 변환할 수 있습니다.
이 메서드의 구현은 다음을 참조하세요 DataObject.SetData.
추가 정보
적용 대상
SetData(Type, Object)
- Source:
- IDataObject.cs
- Source:
- IDataObject.cs
- Source:
- IDataObject.cs
- Source:
- IDataObject.cs
- Source:
- IDataObject.cs
지정된 데이터 및 관련 클래스 형식을 이 인스턴스에 저장합니다.
public:
void SetData(Type ^ format, System::Object ^ data);
public void SetData(Type format, object data);
public void SetData(Type format, object? data);
abstract member SetData : Type * obj -> unit
Public Sub SetData (format As Type, data As Object)
매개 변수
- format
- Type
Type 데이터와 연결된 형식을 나타내는 형식입니다. 미리 정의된 형식은 참조 DataFormats 하세요.
- data
- Object
저장할 데이터입니다.
예제
이 예제에서는 구현 하는 클래스를 DataObject사용 하 여 IDataObject 메서드의 사용을 보여 줍니다SetData. 먼저 구성 요소(myComponent)를 만들고 데이터 형식을 지정하는 데 사용하여 데이터 개체()myDataObject에 myType 저장합니다. 그런 다음, 지정된 형식의 데이터가 개체에 저장되어 있는지 확인하고 결과를 메시지 상자에 표시합니다. 이 예제에서는 명명Form된 이름을 만들었다고 가정합니다Form1.
private:
void SetData3()
{
// Creates a component.
Component^ myComponent = gcnew Component;
// Gets the type of the component.
Type^ myType = myComponent->GetType();
// Creates a data object.
DataObject^ myDataObject = gcnew DataObject;
// Stores the component in the data object.
myDataObject->SetData( myType, myComponent );
// Checks whether data of the specified type is in the data object.
String^ myMessageText;
if ( myDataObject->GetDataPresent( myType ) )
{
myMessageText = "Data of type " + myType->Name +
" is stored in the data object";
}
else
{
myMessageText = "No data of type " + myType->Name +
" is stored in the data object";
}
// Displays the result.
MessageBox::Show( myMessageText, "The Test Result" );
}
private void SetData3()
{
// Creates a component.
Component myComponent = new Component();
// Gets the type of the component.
Type myType = myComponent.GetType();
// Creates a data object.
DataObject myDataObject = new DataObject();
// Stores the component in the data object.
myDataObject.SetData(myType, myComponent);
// Checks whether data of the specified type is in the data object.
string myMessageText;
if(myDataObject.GetDataPresent(myType))
myMessageText = "Data of type " + myType.Name +
" is stored in the data object";
else
myMessageText = "No data of type " + myType.Name +
" is stored in the data object";
// Displays the result.
MessageBox.Show(myMessageText, "The Test Result");
}
Private Sub SetData3()
' Creates a component.
Dim myComponent As New System.ComponentModel.Component()
' Gets the type of the component.
Dim myType As Type = myComponent.GetType()
' Creates a data object.
Dim myDataObject As New DataObject()
' Stores the component in the data object.
myDataObject.SetData(myType, myComponent)
' Checks whether data of the specified type is in the data object.
Dim myMessageText As String
If myDataObject.GetDataPresent(myType) Then
myMessageText = "Data of type " & myType.Name & " is stored in the data object"
Else
myMessageText = "No data of type " & myType.Name & " is stored in the data object"
End If
' Displays the result.
MessageBox.Show(myMessageText, "The Test Result")
End Sub
설명
대상 애플리케이션의 형식을 모르는 경우 이 메서드를 사용하여 여러 형식으로 데이터를 저장할 수 있습니다.
이 메서드를 사용하여 저장된 데이터를 검색할 때 호환되는 형식으로 변환할 수 있습니다.
이 메서드의 구현은 다음을 참조하세요 DataObject.SetData.
추가 정보
적용 대상
SetData(String, Boolean, Object)
- Source:
- IDataObject.cs
- Source:
- IDataObject.cs
- Source:
- IDataObject.cs
- Source:
- IDataObject.cs
- Source:
- IDataObject.cs
부울 값을 사용하여 데이터를 다른 형식으로 변환할 수 있는지 여부를 지정하여 지정된 데이터 및 관련 형식을 이 인스턴스에 저장합니다.
public:
void SetData(System::String ^ format, bool autoConvert, System::Object ^ data);
public void SetData(string format, bool autoConvert, object data);
public void SetData(string format, bool autoConvert, object? data);
abstract member SetData : string * bool * obj -> unit
Public Sub SetData (format As String, autoConvert As Boolean, data As Object)
매개 변수
- format
- String
데이터와 연결된 형식입니다. 미리 정의된 형식은 참조 DataFormats 하세요.
- autoConvert
- Boolean
true데이터를 다른 형식으로 변환할 수 있도록 합니다. 그렇지 않으면 . false
- data
- Object
저장할 데이터입니다.
예제
이 예제에서는 구현 하는 클래스를 DataObject사용 하 여 IDataObject 메서드의 사용을 보여 줍니다SetData. 먼저 데이터 개체(myDataObject)를 만들고 매개 변수가 UnicodeText 로 설정된 autoConvert문자열을 false 저장합니다. 그런 다음 개체에 저장된 데이터와 연결된 형식을 검색하고 메시지 상자에 결과를 표시합니다. 데이터와 연결된 유일한 형식은 형식입니다 UnicodeText . 이 예제에서는 명명Form된 이름을 만들었다고 가정합니다Form1.
private:
void SetData4()
{
// Creates a new data object.
DataObject^ myDataObject = gcnew DataObject;
// Adds UnicodeText string to the object, and set the autoConvert
// parameter to false.
myDataObject->SetData( DataFormats::UnicodeText, false, "My text String*" );
// Gets the data format(s) in the data object.
array<String^>^arrayOfFormats = myDataObject->GetFormats();
// Stores the results in a string.
String^ theResult = "The format(s) associated with the data are: \n";
for ( int i = 0; i < arrayOfFormats->Length; i++ )
theResult = theResult + arrayOfFormats[ i ], " \n";
// Show the results in a message box.
MessageBox::Show( theResult );
}
private void SetData4()
{
// Creates a new data object.
DataObject myDataObject = new DataObject();
// Adds UnicodeText string to the object, and set the autoConvert
// parameter to false.
myDataObject.SetData(DataFormats.UnicodeText, false, "My text string");
// Gets the data format(s) in the data object.
String[] arrayOfFormats = myDataObject.GetFormats();
// Stores the results in a string.
string theResult = "The format(s) associated with the data are:" + '\n';
for(int i=0; i<arrayOfFormats.Length; i++)
theResult += arrayOfFormats[i] + '\n';
// Show the results in a message box.
MessageBox.Show(theResult);
}
Private Sub SetData4()
' Creates a new data object.
Dim myDataObject As New DataObject()
' Adds UnicodeText string to the object, and set the autoConvert
' parameter to false.
myDataObject.SetData(DataFormats.UnicodeText, False, "My text string")
' Gets the data format(s) in the data object.
Dim arrayOfFormats As [String]() = myDataObject.GetFormats()
' Stores the results in a string.
Dim theResult As String = "The format(s) associated with the data are:" + _
ControlChars.Cr
Dim i As Integer
For i = 0 To arrayOfFormats.Length - 1
theResult += arrayOfFormats(i) + ControlChars.Cr
Next i
' Show the results in a message box.
MessageBox.Show(theResult)
End Sub
설명
대상 애플리케이션의 형식을 모르는 경우 이 메서드를 사용하여 여러 형식으로 데이터를 저장할 수 있습니다.
이 메서드의 구현은 다음을 참조하세요 DataObject.SetData.