Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Gibt das Format der Zeichenfolgenklassen in Windows Forms an, in dem Zeichenfolgenobjekte von Windows Forms gespeichert werden. Dieses static-Feld ist schreibgeschützt.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public Shared ReadOnly StringFormat As String
'Usage
Dim value As String
value = DataFormats.StringFormat
public static readonly string StringFormat
public:
static initonly String^ StringFormat
public static final String StringFormat
public static final var StringFormat : String
Hinweise
Dieses Feld wird von der IDataObject-Schnittstelle und der DataObject-Klasse zum Angeben des Datentyps verwendet.
Verwenden Sie dieses Feld beim Hinzufügen zu IDataObject oder zu einer Implementierung von DataObject als Format für die IDataObject.SetData-Methode und die DataObject.SetData-Methode.
Um festzustellen, ob ein Objekt dieses Typs vorhanden ist, verwenden Sie dieses Feld als Format für die IDataObject.GetDataPresent-Methode und die DataObject.GetDataPresent-Methode.
Zum Abrufen eines Objekts dieses Typs verwenden Sie dieses Feld als Format für die IDataObject.GetData-Methode und die DataObject.GetData-Methode.
Hinweis
Das Zeichenklassenformat wird nur für Windows Forms eingesetzt und von Anwendungen, die nicht mit Windows Forms erstellt wurden, nicht erkannt.
Beispiel
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 'Main
End Class 'DataFormats_StringFormat
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 {
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 (System.Exception e) {
Console.WriteLine(e.get_Message());
}
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0
Siehe auch
Referenz
DataFormats-Klasse
DataFormats-Member
System.Windows.Forms-Namespace
GetData
SetData
GetDataPresent
GetFormats
DataObject
IDataObject
GetFormat
DataFormats.Format.Name
DataFormats.Format.Id