Langue

Clipboard.ContainsData(String) Méthode

Définition

Interroge le Presse-papiers pour la présence de données dans un format de données spécifié.

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

Paramètres

format
String

Format des données à rechercher. Consultez DataFormats les formats prédéfinis.

Retours

true si les données au format spécifié sont disponibles dans le Presse-papiers ; sinon, false.

Exceptions

format a la valeur null.

Exemples

L’exemple suivant illustre l’utilisation de cette méthode.


// 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

Remarques

Une requête pour le format Bitmap de données ou FileDrop retournera true si les données peuvent être automatiquement converties au format de données spécifié. Pour les autres formats de données, cette méthode ne retourne true que si le format spécifié est disponible en mode natif dans le Presse-papiers.

S’applique à

Voir aussi