DataFormats.UnicodeText Field

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

Field Value

Type: System.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.

The following code example demonstrates the use of this member.

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


.NET Framework
Available since 1.1
Return to top
Show: