DataFormats::GetFormat Method (String^)
Returns a DataFormats::Format with the Windows Clipboard numeric ID and name for the specified format.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Parameters
- 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.
| Exception | Condition |
|---|---|
| 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 = String::Format( "ID value: {0}\nFormat name: {1}", myFormat->Id, myFormat->Name ); }
Available since 1.1