Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataFormats.StringFormat Field

Specifies the Windows Forms string class format, which Windows Forms uses to store string objects. This static field is read-only.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public static readonly string StringFormat
public static final String StringFormat
public static final var StringFormat : String

This field is used by the IDataObject interface and the DataObject class to specify the data type.

When adding to an IDataObject or to an implementation of DataObject, use this field as the format for the IDataObject.SetData and DataObject.SetData methods.

To see if an object of this type exists, use this field as the format for the IDataObject.GetDataPresent and DataObject.GetDataPresent methods.

To get an object of this type, use this as the format for the IDataObject.GetData and DataObject.GetData methods.

NoteNote

The string class format is specific to Windows Forms only and will not be recognized by applications created outside of Windows Forms.

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());
}

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft