Clipboard.IsCurrent(IDataObject) Methode

Definition

Vergleicht ein angegebenes Datenobjekt mit dem Inhalt der Zwischenablage.

public:
 static bool IsCurrent(System::Windows::IDataObject ^ data);
public static bool IsCurrent (System.Windows.IDataObject data);
static member IsCurrent : System.Windows.IDataObject -> bool
Public Shared Function IsCurrent (data As IDataObject) As Boolean

Parameter

data
IDataObject

Ein Datenobjekt, das mit dem Inhalt der Systemzwischenablage verglichen werden soll.

Gibt zurück

Boolean

true, wenn das angegebene Datenobjekt mit dem Inhalt der Systemzwischenablage übereinstimmt, andernfalls false.

Ausnahmen

data ist null.

Fehler beim Zugriff auf die Zwischenablage. Die Ausnahmedetails schließen ein HResult ein, das den spezifischen Fehler identifiziert. Siehe ErrorCode.

Beispiele

Im folgenden Beispiel wird die Verwendung dieser Methode veranschaulicht.


               // 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)

Hinweise

Verwenden Sie diese Methode, um zu ermitteln, ob ein Datenobjekt, das zuvor in der Zwischenablage platziert wurde, weiterhin vorhanden und nicht geändert ist.

Gilt für