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コントロールの高さ (ポイント単位)。
name
型 : System.StringControlCollection インスタンス内のコントロールにインデックスを作成するために使用できる名前。
戻り値
型 : Microsoft.Office.Tools.Word.Controls.CheckedListBox
ControlCollection インスタンスに追加された CheckedListBox コントロール。
例外
例外 | 条件 |
---|---|
ArgumentNullException | name 引数が nullnull 参照 (Visual Basic では Nothing) であるか、または長さが 0 である場合。 |
ControlNameAlreadyExistsException | 同じ名前のコントロールが既に ControlCollection インスタンスに存在する場合。 |
解説
このメソッドを使用すると、CheckedListBox オブジェクトを ControlCollection の最後に追加できます。
プログラムで追加された CheckedListBox を削除するには、Remove メソッドを使用します。
例
次のコード例は、CheckedListBox コントロールを文書の先頭に追加し、2 つの項目をチェックされたリスト ボックスに追加してから、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);
}
アクセス許可
- 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。