This documentation is archived and is not being maintained.

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 DataFormats..::..Format GetFormat(
	string format


Type: System.String
The format name.

Return Value

Type: System.Windows.Forms.DataFormats.Format
A DataFormats.Format that has the Windows Clipboard numeric ID and the name of the format.


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;

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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