<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>运行时添加 Windows 窗体控件</Title>
      <Author>Microsoft Corporation</Author>
      <Description>运行时新建 Windows 窗体 TextBox 控件的实例。</Description>
      <Shortcut>formAdd</Shortcut>
    </Header>
    <Snippet>
      <References>
        <Reference>
          <Assembly>System.Drawing.dll</Assembly>
        </Reference>
        <Reference>
          <Assembly>System.Windows.Forms.dll</Assembly>
        </Reference>
        <Reference>
          <Assembly>System.dll</Assembly>
        </Reference>
      </References>
      <Imports>
        <Import>
          <Namespace>Microsoft.VisualBasic</Namespace>
        </Import>
        <Import>
          <Namespace>System</Namespace>
        </Import>
        <Import>
          <Namespace>System.Drawing</Namespace>
        </Import>
        <Import>
          <Namespace>System.Windows.Forms</Namespace>
        </Import>
      </Imports>
      <Declarations>
        <Literal>
          <ID>text</ID>
          <Type>String</Type>
          <ToolTip>要在 Windows 窗体控件中显示的文本。</ToolTip>
          <Default>"TextBox1"</Default>
        </Literal>
        <Literal>
          <ID>locationX</ID>
          <Type>Integer</Type>
          <ToolTip>控件位置的 X 坐标。</ToolTip>
          <Default>64</Default>
        </Literal>
        <Literal>
          <ID>locationY</ID>
          <Type>Integer</Type>
          <ToolTip>控件位置的 Y 坐标。</ToolTip>
          <Default>40</Default>
        </Literal>
        <Literal>
          <ID>width</ID>
          <Type>Integer</Type>
          <ToolTip>控件的宽度。</ToolTip>
          <Default>100</Default>
        </Literal>
        <Literal>
          <ID>height</ID>
          <Type>Integer</Type>
          <ToolTip>控件的高度。</ToolTip>
          <Default>20</Default>
        </Literal>
        <Object>
          <ID>controlType</ID>
          <Type>Control</Type>
          <ToolTip>替换为要添加的控件的类型。</ToolTip>
          <Default>TextBox</Default>
        </Object>
        <Literal>
          <ID>controlName</ID>
          <Type>String</Type>
          <ToolTip>控件的变量名称。</ToolTip>
          <Default>TextBox1</Default>
        </Literal>
        <Literal>
          <ID>tabIndex</ID>
          <Type>Integer</Type>
          <ToolTip>Tab 键顺序值。</ToolTip>
          <Default>0</Default>
        </Literal>
      </Declarations>
      <Code Language="VB" Kind="method body"><![CDATA[    Dim $controlName$ As New $controlType$()
    With $controlName$
        .Location = New Point($locationX$, $locationY$)
        .Size = New Size($width$, $height$)
        .TabIndex = $tabIndex$
        .Text = $text$
    End With
    Controls.Add($controlName$)

]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>
