This documentation is archived and is not being maintained.

DataFormats.UnicodeText Field

Specifies the standard Windows Unicode text format. This static field is read-only.

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

public static readonly string UnicodeText
public static final String UnicodeText
public static final var UnicodeText : 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.

try
{

    String myString = "This is a String from the ClipBoard";
      
    // Sets the data into the Clipboard.
    Clipboard.SetDataObject(myString);
    IDataObject myDataObject = Clipboard.GetDataObject();
    // Checks whether the format of the data is 'UnicodeText' or not.
    if(myDataObject.GetDataPresent(DataFormats.UnicodeText)) 
    {
        Console.WriteLine("Data in 'UnicodeText' format:"+myDataObject.GetData(DataFormats.UnicodeText));
    } 
    else 
    {
        Console.WriteLine("No String information was contained in the clipboard.");
    }

    // Checks whether the format of the data is 'Text' or not.
    if(myDataObject.GetDataPresent(DataFormats.Text)) 
    {
        String clipString = (String)myDataObject.GetData(DataFormats.StringFormat);
        Console.WriteLine("Data in 'Text' format:"+clipString);
    }
}
catch(Exception e)
{
    Console.WriteLine(e.Message);
}

      

try {
    String myString = "This is a String from the ClipBoard";

    // Sets the data into the Clipboard.
    Clipboard.SetDataObject(myString);
    IDataObject myDataObject = Clipboard.GetDataObject();

    // Checks whether the format of the data is 'UnicodeText' or not.
    if (myDataObject.GetDataPresent(DataFormats.UnicodeText)) {
        Console.WriteLine("Data in 'UnicodeText' format:" 
            + myDataObject.GetData(DataFormats.UnicodeText));
    }
    else {
        Console.WriteLine("No String information was contained "
            + "in the clipboard.");
    }

    // Checks whether the format of the data is 'Text' or not.
    if (myDataObject.GetDataPresent(DataFormats.Text)) {
        String clipString = (String)(myDataObject.
            GetData(DataFormats.StringFormat));
        Console.WriteLine("Data in 'Text' format:" + clipString);
    }
}
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
Show: