DataFormats.Format(String, Int32) 构造函数

定义

用一个布尔值对 DataFormats.Format 类的新实例进行初始化,此布尔值指示是否需要 Win32 句柄。Initializes a new instance of the DataFormats.Format class with a Boolean that indicates whether a Win32 handle is expected.

public:
 Format(System::String ^ name, int id);
public Format (string name, int id);
new System.Windows.Forms.DataFormats.Format : string * int -> System.Windows.Forms.DataFormats.Format
Public Sub New (name As String, id As Integer)

参数

name
String

该格式的名称。The name of this format.

id
Int32

此格式的 ID 号。The ID number for this format.

示例

下面的代码示例将为名称和唯一 ID 号创建新的格式。The following code example creates a new format for a name and unique ID number. 新格式不需要 Windows 句柄。The new format does not require a Windows handle. 它要求textBox1已实例化。It requires that textBox1 has been instantiated.

private:
   void CreateMyFormat2()
   {
      DataFormats::Format^ myFormat = gcnew DataFormats::Format(
         "AnotherNewFormat", 20916 );
      
      // Displays the contents of myFormat.
      textBox1->Text = String::Format( "ID value: {0}\nFormat name: {1}",
         myFormat->Id, myFormat->Name );
   }
private void CreateMyFormat2() {
    DataFormats.Format myFormat = new DataFormats.Format("AnotherNewFormat", 20916);
 
    // Displays the contents of myFormat.
    textBox1.Text = "ID value: " + myFormat.Id + '\n' +
       "Format name: " + myFormat.Name;
 }
 
Private Sub CreateMyFormat2()
    Dim myFormat As New DataFormats.Format("AnotherNewFormat", 20916)
       
    ' Displays the contents of myFormat.
    textBox1.Text = "ID value: " + myFormat.Id.ToString() + ControlChars.Cr _
                  + "Format name: " + myFormat.Name
End Sub

适用于