Clipboard.SetDataObject 메서드

정의

시스템 클립보드에 지정된 데이터 개체를 저장합니다.

오버로드

Name Description
SetDataObject(Object)

시스템 클립보드에 지정된 비영구 데이터 개체를 배치합니다.

SetDataObject(Object, Boolean)

시스템 클립보드에 지정된 데이터 개체를 배치하고 애플리케이션이 종료될 때 데이터 개체를 클립보드에 남겨둘지 여부를 나타내는 부울 매개 변수를 허용합니다.

SetDataObject(Object)

시스템 클립보드에 지정된 비영구 데이터 개체를 배치합니다.

public:
 static void SetDataObject(System::Object ^ data);
[System.Security.SecurityCritical]
public static void SetDataObject(object data);
public static void SetDataObject(object data);
[<System.Security.SecurityCritical>]
static member SetDataObject : obj -> unit
static member SetDataObject : obj -> unit
Public Shared Sub SetDataObject (data As Object)

매개 변수

data
Object

시스템 클립보드에 배치할 데이터 개체(구현하는 개체)입니다 IDataObject.

특성

예외

datanull입니다.

클립보드에 액세스할 때 오류가 발생했습니다. 예외 세부 정보에는 특정 오류를 HResult식별하는 항목이 포함 ErrorCode 됩니다.

설명

기본적으로 시스템 클립보드 SetDataObject 에 배치된 데이터는 애플리케이션이 종료될 때 클립보드에서 자동으로 지워집니다.

메모

애플리케이션 종료 시 클립보드를 지우는 기본 동작은 다른 구현과 다를 수 있으며, 기본적으로 클립보드를 지우지 않고 애플리케이션 종료 시 클립보드에 데이터를 남길 수 있습니다. 오버로드를 SetDataObject 사용하고 애플리케이션 종료의 copy 클립보드에서 데이터를 지우지 않으려는 것처럼 true 매개 변수를 지정합니다.

DataObject 는 인터페이스의 기본 구현을 IDataObject 제공합니다.

추가 정보

적용 대상

SetDataObject(Object, Boolean)

시스템 클립보드에 지정된 데이터 개체를 배치하고 애플리케이션이 종료될 때 데이터 개체를 클립보드에 남겨둘지 여부를 나타내는 부울 매개 변수를 허용합니다.

public:
 static void SetDataObject(System::Object ^ data, bool copy);
[System.Security.SecurityCritical]
public static void SetDataObject(object data, bool copy);
public static void SetDataObject(object data, bool copy);
[<System.Security.SecurityCritical>]
static member SetDataObject : obj * bool -> unit
static member SetDataObject : obj * bool -> unit
Public Shared Sub SetDataObject (data As Object, copy As Boolean)

매개 변수

data
Object

시스템 클립보드에 배치할 데이터 개체(구현하는 개체)입니다 IDataObject.

copy
Boolean

true 애플리케이션이 종료되면 시스템 클립보드에 데이터를 남겨 둡니다. false 애플리케이션이 종료되면 시스템 클립보드에서 데이터를 지웁니다.

특성

예외

datanull입니다.

클립보드에 액세스할 때 오류가 발생했습니다. 예외 세부 정보에는 특정 오류를 HResult식별하는 항목이 포함 ErrorCode 됩니다.

예제

다음 예제에서는이 메서드의 사용을 보여 줍니다.


               // For this example, the data to be placed on the clipboard is a simple
               // string.
               string textData = "I want to put this string on the clipboard.";
               // The example will enable auto-conversion of data for this data object.
               bool autoConvert = true;

               // Create a new data object, specifying the data format, data to encapsulate, and enabling
               // auto-conversion services.
               DataObject data = new DataObject(DataFormats.UnicodeText, (Object)textData, autoConvert);
               
               // If the data to be copied is supposed to be persisted after the application ends, 
               // then set the second parameter of SetDataObject to true.
               if(persistentData)
               {
                   // Place the persisted data on the clipboard.
                   Clipboard.SetDataObject(data, true);
               }
               else
               {
                   // Place the non-persisted data on the clipboard.
                   Clipboard.SetDataObject(data, false);
               }

               // If you keep a copy of the source data object, you can use the IsCurrent method to see if
               // the data object is still on the clipboard.
               bool isOriginalDataObject = Clipboard.IsCurrent(data);

' For this example, the data to be placed on the clipboard is a simple
' string.
Dim textData As String = "I want to put this string on the clipboard."
' The example will enable auto-conversion of data for this data object.
Dim autoConvert As Boolean = True

' Create a new data object, specifying the data format, data to encapsulate, and enabling
' auto-conversion services.
Dim data As New DataObject(DataFormats.UnicodeText, CType(textData, Object), autoConvert)

' If the data to be copied is supposed to be persisted after the application ends, 
' then set the second parameter of SetDataObject to true.
If persistentData Then
    ' Place the persisted data on the clipboard.
    Clipboard.SetDataObject(data, True)
Else
    ' Place the non-persisted data on the clipboard.
    Clipboard.SetDataObject(data, False)
End If

' If you keep a copy of the source data object, you can use the IsCurrent method to see if
' the data object is still on the clipboard.
Dim isOriginalDataObject As Boolean = Clipboard.IsCurrent(data)

설명

DataObject 는 인터페이스의 기본 구현을 IDataObject 제공합니다. IsCurrent 는 마지막 SetDataObject 호출에 의해 이전에 클립보드에 배치된 데이터 개체를 결정합니다.

추가 정보

적용 대상