ListWidth 属性示例
下例用数值调节钮来控制组合框的下拉列表的宽度。用户改变数值调节钮的值,然后再单击组合框的下拉箭头来显示列表。
窗体包含:
- 名为 ComboBox1 的组合框。
- 名为 SpinButton1 的数值调节钮。
- 名为 Label1 的标签。
Sub UserForm_SpinButton1_Change()
UserForm_ComboBox1.ListWidth = UserForm_SpinButton1.Value
UserForm_Label1.Caption = "ListWidth = " & UserForm_SpinButton1.Value
End Sub
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 = 130
UserForm_SpinButton1.Value = 0
UserForm_SpinButton1.SmallChange = 5
UserForm_Label1.Caption = "ListWidth = " & UserForm_SpinButton1.Value
End Sub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22