This documentation is archived and is not being maintained.

Clipboard.ContainsData Method

Queries the Clipboard for the presence of data in a specified data format.

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)

public static bool ContainsData(
	string format


Type: System.String
The format of the data to look for. See DataFormats for predefined formats.

Return Value

Type: System.Boolean
true if data in the specified format is available on the Clipboard; otherwise, false. See Remarks.


format is null.

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.

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;

                    htmlData = Clipboard.GetText(TextDataFormat.Html);


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.