Clipboard.IsCurrent(IDataObject) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Compares a specified data object to the contents of the Clipboard.
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
- data
- IDataObject
A data object to compare to the contents of the system Clipboard.
true
if the specified data object matches what is on the system Clipboard; otherwise, false
.
data
is null
.
An error occurred when accessing the Clipboard. The exception details will include an HResult
that identifies the specific error; see ErrorCode.
The following example demonstrates the use of this method.
// 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)
Use this method to determine if a data object that was previously placed on the Clipboard is still present and unmodified.
Producto | Versiones |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
Comentarios de .NET
.NET es un proyecto de código abierto. Seleccione un vínculo para proporcionar comentarios: