.NET Framework Class Library
Clipboard.IsCurrent Method
Compares a specified data object to the contents of the Clipboard.
Assembly: PresentationCore (in PresentationCore.dll)
Syntax
Visual Basic
Public Shared Function IsCurrent ( _ data As IDataObject _ ) As Boolean
C#
public static bool IsCurrent( IDataObject data )
Visual C++
public: static bool IsCurrent( IDataObject^ data )
F#
static member IsCurrent : data:IDataObject -> bool
Parameters
- data
- Type: System.Windows.IDataObject
A data object to compare to the contents of the system Clipboard.
Return Value
Type: System.Booleantrue if the specified data object matches what is on the system Clipboard; otherwise, false.
Exceptions
| Exception | Condition |
|---|---|
| ArgumentNullException |
data is null. |
| ExternalException |
An error occurred when accessing the Clipboard. The exception details will include an HResult that identifies the specific error; see ErrorWrapper.ErrorCode. |
Remarks
Use this method to determine if a data object that was previously placed on the Clipboard is still present and unmodified.
Examples
The following example demonstrates the use of this method.
Visual Basic
' 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)
C#
// 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);
Version Information
.NET Framework
Supported in: 4, 3.5, 3.0.NET Framework Client Profile
Supported in: 4, 3.5 SP1Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
See Also