ListRows 属性示例
下例中,用数值调节钮来控制组合框的下拉列表中的行数。用户改变数值调节钮的值,然后单击组合框的下拉箭头来显示列表。
窗体包含:
- 名为 ComboBox1 的组合框。
- 名为 SpinButton1 的数值调节钮。
- 名为 Label1 的标签。
Sub UserForm_Initialize()
Dim i
For i = 1 To 20
UserForm_ComboBox1.AddItem "Choice " & (UserForm_ComboBox1.ListCount + 1)
Next
UserForm_SpinButton1.Min = 0
UserForm_SpinButton1.Max = 12
UserForm_SpinButton1.Value = UserForm_ComboBox1.ListRows
UserForm_Label1.Caption = "ListRows = " & UserForm_SpinButton1.Value
End Sub
Sub UserForm_SpinButton1_Change()
UserForm_ComboBox1.ListRows = UserForm_SpinButton1.Value
UserForm_Label1.Caption = "ListRows = " & UserForm_SpinButton1.Value
End Sub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18