DataFormats.StringFormat Feld

Definition

Gibt das Windows Forms Zeichenfolgenklassenformat an, das Windows Forms zum Speichern von Zeichenfolgenobjekten verwendet. Dieses static Feld ist schreibgeschützt.

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

Feldwert

Beispiele

Im folgenden Codebeispiel wird die Verwendung dieses Elements veranschaulicht.

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

Hinweise

Dieses Feld wird von der IDataObject Schnittstelle und der DataObject Klasse verwendet, um den Datentyp anzugeben.

Verwenden Sie dieses Feld beim Hinzufügen zu einer IDataObject Oder-Implementierung DataObjectals Format für die IDataObject.SetData und DataObject.SetData methoden.

Um festzustellen, ob ein Objekt dieses Typs vorhanden ist, verwenden Sie dieses Feld als Format für die IDataObject.GetDataPresent und DataObject.GetDataPresent methoden.

Um ein Objekt dieses Typs abzurufen, verwenden Sie dies als Format für die IDataObject.GetData und DataObject.GetData methoden.

Note

Das Zeichenfolgenklassenformat ist nur für Windows Forms spezifisch und wird von Anwendungen, die außerhalb von Windows Forms erstellt wurden, nicht erkannt.

Gilt für:

Weitere Informationen