DataFormats.GetFormat DataFormats.GetFormat DataFormats.GetFormat DataFormats.GetFormat Method

定义

返回带有 Windows 剪贴板数字 ID 和名称的 DataFormats.FormatReturns a DataFormats.Format with the Windows Clipboard numeric ID and name.

重载

GetFormat(Int32) GetFormat(Int32) GetFormat(Int32) GetFormat(Int32)

为指定的 ID 返回带有 Windows 剪贴板数字 ID 和名称的 DataFormats.FormatReturns a DataFormats.Format with the Windows Clipboard numeric ID and name for the specified ID.

GetFormat(String) GetFormat(String) GetFormat(String)

为指定的格式返回带有 Windows 剪贴板数字 ID 和名称的 DataFormats.FormatReturns a DataFormats.Format with the Windows Clipboard numeric ID and name for the specified format.

GetFormat(Int32) GetFormat(Int32) GetFormat(Int32) GetFormat(Int32)

为指定的 ID 返回带有 Windows 剪贴板数字 ID 和名称的 DataFormats.FormatReturns a DataFormats.Format with the Windows Clipboard numeric ID and name for the specified ID.

public:
 static System::Windows::Forms::DataFormats::Format ^ GetFormat(int id);
public static System.Windows.Forms.DataFormats.Format GetFormat (int id);
static member GetFormat : int -> System.Windows.Forms.DataFormats.Format
Public Shared Function GetFormat (id As Integer) As DataFormats.Format

参数

id
Int32 Int32 Int32 Int32

格式 ID。The format ID.

返回

一个 DataFormats.Format,它具有 Windows 剪贴板数字 ID 和格式的名称。A DataFormats.Format that has the Windows Clipboard numeric ID and the name of the format.

示例

下面的代码示例演示如何将此成员。The following code example demonstrates the use of this member.

using namespace System;
using namespace System::Windows::Forms;
int main()
{
   
   // Create a DataFormats::Format for the Unicode data format.
   DataFormats::Format^ myFormat = DataFormats::GetFormat( 13 );
   
   // Display the contents of myFormat.
   Console::WriteLine( "The Format Name corresponding to the ID {0} is :", myFormat->Id );
   Console::WriteLine( myFormat->Name );
}

using System;
using System.Windows.Forms;

   public class DataFormat_GetFormat
   {
      static void Main()
      {

         // Create a DataFormats.Format for the Unicode data format.
         DataFormats.Format myFormat = DataFormats.GetFormat(13);

         // Display the contents of myFormat.
         Console.WriteLine("The Format Name corresponding to the ID "+myFormat.Id+" is :");
         Console.WriteLine(myFormat.Name);

         

      }
   }
Imports System
Imports System.Windows.Forms
Imports Microsoft.Visualbasic


Public Class DataFormat_GetFormat
   
   Shared Sub Main()
      
     ' Create a DataFormats.Format for the Unicode data format.

      Dim myFormat As DataFormats.Format = DataFormats.GetFormat(13)

      ' Display the contents of myFormat.

      Console.WriteLine(("The Format Name corresponding to the ID " + myFormat.Id.ToString + " is :"))
      Console.WriteLine(myFormat.Name)

   End Sub 'Main 

End Class 'DataFormat_GetFormat 

注解

此成员通常用于注册本机剪贴板格式。This member is typically used to register native Clipboard formats.

调用GetFormat当你想要检索一个 ID 号DataFormats.Format实例,它包含 ID/格式名称对。Call GetFormat with an ID number when you want to retrieve a DataFormats.Format instance that contains the ID/format name pair. 通常情况下,由正在使用的应用程序的创建者发布的标识名称和数量Clipboard与进行交互。Typically, the ID name and number is published by the creator of the application that you are using the Clipboard to interface with. 例如,在 Visual Basic 中的动态数据交换 (DDE) 会话信息的 ID 号是&HBF00,且格式名称将为vbCFLinkFor example, the ID number for Dynamic Data Exchange (DDE) conversation information in Visual Basic is &HBF00, and the format name is vbCFLink.

调用此方法与 ID/格式名称将对添加到任何唯一 ID 号static的格式名称/ID 对列表中DataFormats类。Call this method with any unique ID number to add the ID/format name pair to the static list of format name/ID pairs in the DataFormats class. 通过连接"格式"和 ID 号,将创建新的名称。The new name will be created by concatenating "Format" and the ID number. 此对未注册为新Clipboard格式,因为你未提供一个名称。This pair is not registered as a new Clipboard format because you have not provided a name.

另请参阅

GetFormat(String) GetFormat(String) GetFormat(String)

为指定的格式返回带有 Windows 剪贴板数字 ID 和名称的 DataFormats.FormatReturns a DataFormats.Format with the Windows Clipboard numeric ID and name for the specified format.

public:
 static System::Windows::Forms::DataFormats::Format ^ GetFormat(System::String ^ format);
public static System.Windows.Forms.DataFormats.Format GetFormat (string format);
static member GetFormat : string -> System.Windows.Forms.DataFormats.Format

参数

format
String String String String

格式名。The format name.

返回

一个 DataFormats.Format,它具有 Windows 剪贴板数字 ID 和格式的名称。A DataFormats.Format that has the Windows Clipboard numeric ID and the name of the format.

异常

注册新的 Clipboard 格式失败。Registering a new Clipboard format failed.

示例

下面的代码示例演示如何检索DataFormats.Format表示格式名称/ID 对。The following code example shows how to retrieve a DataFormats.Format representing a format name/ID pair. UnicodeText请求格式,以及检索到的内容DataFormats.Format显示在文本框中。The UnicodeText format is requested, and the contents of the retrieved DataFormats.Format are displayed in a text box.

此代码需要textBox1已实例化。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 );
   }
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 Sub GetMyFormatInfomation()
    ' Creates a DataFormats.Format for the Unicode data format.
    Dim myFormat As DataFormats.Format = _
       DataFormats.GetFormat(DataFormats.UnicodeText)
       
    ' Displays the contents of myFormat.
    textBox1.Text = "ID value: " + myFormat.Id.ToString() + ControlChars.Cr _
                  + "Format name: " + myFormat.Name
End Sub

注解

调用GetFormat时需要 Windows 剪贴板数字 ID 的现有格式的格式名。Call GetFormat with the format name when you need a Windows Clipboard numeric ID for an existing format.

调用此方法使用你自己的格式名称来创建一个新Clipboard格式类型。Call this method with your own format name to create a new Clipboard format type. 如果指定的格式不存在,此方法将该名称注册为使用 Windows 注册表的剪贴板格式,并获取格式唯一标识符。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. 此新的名称/ID 对将添加到static的格式名称/ID 对列表中DataFormats类。This new name/ID pair will be added to the static list of format name/ID pairs in the DataFormats class.

另请参阅

适用于