Export (0) Print
Expand All

DataFormats.GetFormat Method (String)

Returns a DataFormats.Format with the Windows Clipboard numeric ID and name for the specified format.

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

public static Format GetFormat (
	string format
)
public static Format GetFormat (
	String format
)
public static function GetFormat (
	format : String
) : Format

Parameters

format

The format name.

Return Value

A DataFormats.Format that has the Windows Clipboard numeric ID and the name of the format.

Exception typeCondition

Win32Exception

Registering a new Clipboard format failed.

Call GetFormat with the format name when you need a Windows Clipboard numeric ID for an existing format.

Call this method with your own format name to create a new Clipboard format type. If the specified format does not exist, this method will register the name as a Clipboard format with the Windows registry and get a unique format identifier. This new name/ID pair will be added to the static list of format name/ID pairs in the DataFormats class.

The following code example shows how to retrieve a DataFormats.Format representing a format name/ID pair. The UnicodeText format is requested, and the contents of the retrieved DataFormats.Format are displayed in a text box.

This code requires textBox1 has been instantiated.

private void GetMyFormatInfomation() {
   // Creates a DataFormats.Format for the Unicode data format.
   DataFormats.Format myFormat = DataFormats.GetFormat(DataFormats.UnicodeText);

   // Displays the contents of myFormat.
   textBox1.Text = "ID value: " + myFormat.Id + '\n' +
      "Format name: " + myFormat.Name;
}


private void GetMyFormatInfomation()
{
    // Creates a DataFormats.Format for the Unicode data format.
    DataFormats.Format myFormat = 
        DataFormats.GetFormat(DataFormats.UnicodeText);

    // Displays the contents of myFormat.
    textBox1.set_Text("ID value: "
        + myFormat.get_Id() + '\n' + "Format name: " + myFormat.get_Name());
} //GetMyFormatInfomation

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

Community Additions

ADD
Show:
© 2014 Microsoft