Locked、DropButtonStyle 和 ShowDropButtonWhen 属性示例
下例中,演示在组合框或文本框中,可为下拉箭头指定的不同符号。在本示例中,用户可从组合框中选择一个下拉箭头的类型。该示例还使用了 Locked 属性。若要使
窗体包含:
- 名为 ComboBox1 的组合框。
- 名为 Label1 的标签。
- 置于 Label1 之下的名为 TextBox1 的文本框。
Sub UserForm_ComboBox1_Click()
UserForm_ComboBox1.DropButtonStyle = UserForm_ComboBox1.Value
UserForm_TextBox1.DropButtonStyle = UserForm_ComboBox1.Value
End Sub
Sub UserForm_Initialize()
UserForm_ComboBox1.ColumnCount = 2
UserForm_ComboBox1.BoundColumn = 2
UserForm_ComboBox1.TextColumn = 1
UserForm_ComboBox1.AddItem "Blank Button"
UserForm_ComboBox1.List(0, 1) = 0
UserForm_ComboBox1.AddItem "Down Arrow"
UserForm_ComboBox1.List(1, 1) = 1
UserForm_ComboBox1.AddItem "Ellipsis"
UserForm_ComboBox1.List(2, 1) = 2
UserForm_ComboBox1.AddItem "Underscore"
UserForm_ComboBox1.List(3, 1) = 3
UserForm_ComboBox1.Value = 0
UserForm_TextBox1.Text = "TextBox1"
UserForm_TextBox1.ShowDropButtonWhen = 2
UserForm_TextBox1.Locked = True
UserForm_Label1.Caption = "TheDropButton also applies to a TextBox."
UserForm_Label1.AutoSize = True
UserForm_Label1.WordWrap = False
End Sub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30