Clipboard.ContainsData Method
Queries the Clipboard for the presence of data in a specified data format.
Assembly: PresentationCore (in PresentationCore.dll)
Parameters
- format
- Type: System.String
The format of the data to look for. See DataFormats for predefined formats.
Return Value
Type: System.Booleantrue if data in the specified format is available on the Clipboard; otherwise, false. See Remarks.
| Exception | Condition |
|---|---|
| ArgumentNullException |
format is null. |
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);
}
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.