DataFormats.StringFormat Champ

Définition

Spécifie le format de la classe de la chaîne des Windows Forms utilisé par les Windows Forms pour stocker des objets chaîne. Ce champ static est en lecture seule.

public: static initonly System::String ^ StringFormat;
public static readonly string StringFormat;
 staticval mutable StringFormat : string
Public Shared ReadOnly StringFormat As String 

Valeur de champ

String

Exemples

L’exemple de code suivant illustre l’utilisation de ce membre.

try
{
   String^ myString = "This is a String from the ClipBoard";
   // Sets the data to the Clipboard.   
   Clipboard::SetDataObject( myString );
   IDataObject^ myDataObject = Clipboard::GetDataObject();
   
   // Checks whether the data is present or not in the Clipboard.
   if ( myDataObject->GetDataPresent( DataFormats::StringFormat ) )
   {
      String^ clipString = (String^)(myDataObject->GetData( DataFormats::StringFormat ));
      Console::WriteLine( clipString );
   }
   else
   {
      Console::WriteLine( "No String information was contained in the clipboard." );
   }
}
catch ( Exception^ e ) 
{
   Console::WriteLine( e->Message );
}
try
{
    String myString = "This is a String from the ClipBoard";
    // Sets the data to the Clipboard.   
    Clipboard.SetDataObject(myString);
    IDataObject myDataObject = Clipboard.GetDataObject();

    // Checks whether the data is present or not in the Clipboard.
    if(myDataObject.GetDataPresent(DataFormats.StringFormat)) 
    {
        String clipString = (String)myDataObject.GetData(DataFormats.StringFormat);
        Console.WriteLine(clipString);
    } 
    else 
    {
        Console.WriteLine("No String information was contained in the clipboard.");
    }
}
catch(Exception e)
{
    Console.WriteLine(e.Message);
}
        Try
            Dim myString As String = "This is a String from the ClipBoard"
            ' Sets the data to the Clipboard.   
            Clipboard.SetDataObject(myString)
            Dim myDataObject As IDataObject = Clipboard.GetDataObject()
          
            ' Checks whether the data is present or not in the Clipboard.
            If myDataObject.GetDataPresent(DataFormats.StringFormat) Then
                Dim clipString As String = CType(myDataObject.GetData(DataFormats.StringFormat), String)
                Console.WriteLine(clipString)
            Else
                Console.WriteLine("No String information was contained in the clipboard.")
            End If
        Catch e As Exception
            Console.WriteLine(e.Message)
        End Try
   End Sub
End Class

Remarques

Ce champ est utilisé par l’interface IDataObject et la DataObject classe pour spécifier le type de données.

Lors de l’ajout à une implémentation ou à une IDataObject implémentation de DataObject, utilisez ce champ comme format pour les méthodes et DataObject.SetData les IDataObject.SetData méthodes.

Pour voir si un objet de ce type existe, utilisez ce champ comme format pour les méthodes et DataObject.GetDataPresent les IDataObject.GetDataPresent méthodes.

Pour obtenir un objet de ce type, utilisez-le comme format pour les méthodes et DataObject.GetData les IDataObject.GetData méthodes.

Notes

Le format de classe de chaîne est spécifique à Windows Forms uniquement et ne sera pas reconnu par les applications créées en dehors de Windows Forms.

S’applique à

Voir aussi