ControlCollection.AddCheckedListBox 方法 (Single, Single, Single, Single, String) (2007 system)

更新:2007 年 11 月

按照指定的大小和位置向文档中添加一个新的 CheckedListBox 控件。

命名空间:  Microsoft.Office.Tools.Word
程序集:  Microsoft.Office.Tools.Word.v9.0(在 Microsoft.Office.Tools.Word.v9.0.dll 中)

语法

声明
Public Function AddCheckedListBox ( _
    left As Single, _
    top As Single, _
    width As Single, _
    height As Single, _
    name As String _
) As CheckedListBox
用法
Dim instance As ControlCollection
Dim left As Single
Dim top As Single
Dim width As Single
Dim height As Single
Dim name As String
Dim returnValue As CheckedListBox

returnValue = instance.AddCheckedListBox(left, _
    top, width, height, name)
public CheckedListBox AddCheckedListBox(
    float left,
    float top,
    float width,
    float height,
    string name
)

参数

  • left
    类型:System.Single

    控件左边缘与文档左边缘之间的距离(以磅为单位)。

  • top
    类型:System.Single

    控件上边缘和文档上边缘之间的距离(以磅为单位)。

  • width
    类型:System.Single

    控件的宽度(以磅为单位)。

  • height
    类型:System.Single

    控件的高度(以磅为单位)。

返回值

类型:Microsoft.Office.Tools.Word.Controls.CheckedListBox

添加到 ControlCollection 实例的 CheckedListBox 控件。

异常

异常 条件
ArgumentNullException

name 参数为 nullnull 引用(在 Visual Basic 中为 Nothing) 或长度为零。

ControlNameAlreadyExistsException

ControlCollection 实例中已存在一个同名控件。

备注

此方法使您能够将 CheckedListBox 对象添加到 ControlCollection 的末尾。

若要移除通过编程方式添加的 CheckedListBox,请使用 Remove 方法。

示例

下面的代码示例向文档开头添加一个 CheckedListBox 控件,向该复选列表框添加两个项,然后选择 First Item 复选框。

Private Sub WordAddCheckedListBox()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Dim CheckedListBox1 As Microsoft.Office.Tools.Word. _
        Controls.CheckedListBox = Me.Controls.AddCheckedListBox( _
        0, 0, 90, 66.75F, "CheckedListBox1")
    CheckedListBox1.Items.Add("First Item")
    CheckedListBox1.Items.Add("Second Item")
    CheckedListBox1.SetItemChecked(0, True)

End Sub 

private void WordAddCheckedListBox()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Controls.CheckedListBox
        checkedListBox1 = this.Controls.AddCheckedListBox(
        0, 0, 90, 66.75F, "checkedListBox1");
    checkedListBox1.Items.Add("First Item");
    checkedListBox1.Items.Add("Second Item");
    checkedListBox1.SetItemChecked(0, true);
}

权限

另请参见

参考

ControlCollection 类

ControlCollection 成员

AddCheckedListBox 重载

Microsoft.Office.Tools.Word 命名空间