Clipboard.ContainsData(String) Method
Definition
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.
Queries the Clipboard for the presence of data in a specified data format.
public:
static bool ContainsData(System::String ^ format);
public static bool ContainsData (string format);
static member ContainsData : string -> bool
Public Shared Function ContainsData (format As String) As Boolean
Parameters
- format
- String
The format of the data to look for. See DataFormats for predefined formats.
Returns
true
if data in the specified format is available on the Clipboard; otherwise, false
.
Exceptions
format
is null
.
Examples
The following example demonstrates the use of this method.
// After this line executes, IsHTMLDataOnClipboard will be true if
// HTML data is available natively on the clipboard; if not, it
// will be false.
bool IsHTMLDataOnClipboard = Clipboard.ContainsData(DataFormats.Html);
// If there is HTML data on the clipboard, retrieve it.
string htmlData;
if(IsHTMLDataOnClipboard)
{
htmlData = Clipboard.GetText(TextDataFormat.Html);
}
' After this line executes, IsHTMLDataOnClipboard will be true if
' HTML data is available natively on the clipboard; if not, it
' will be false.
Dim IsHTMLDataOnClipboard As Boolean = Clipboard.ContainsData(DataFormats.Html)
' If there is HTML data on the clipboard, retrieve it.
Dim htmlData As String
If IsHTMLDataOnClipboard Then
htmlData = Clipboard.GetText(TextDataFormat.Html)
End If
Remarks
A query for the data format Bitmap or FileDrop will return true
if the data can be automatically converted to the specified data format. For other data formats, this method returns true
only if the specified format is available natively on the Clipboard.