Alignment 属性示例
下例演示几个选项按钮控件一起使用时的 Alignment 属性。本示例中,用户可以通过单击切换按钮来更改对齐格式。
窗体包括:
- 名为 OptionButton1 和 OptionButton2 的两个选项按钮控件。
- 名为 ToggleButton1 的切换按钮。
Sub UserForm_Initialize()
UserForm_OptionButton1.Alignment = 0
UserForm_OptionButton2.Alignment = 0
UserForm_OptionButton1.Caption = "Alignment with AutoSize"
UserForm_OptionButton2.Caption = "Choice 2"
UserForm_OptionButton1.AutoSize = True
UserForm_OptionButton2.AutoSize = True
UserForm_ToggleButton1.Caption = "Left Align"
UserForm_ToggleButton1.WordWrap = True
UserForm_ToggleButton1.Value = True
End Sub
Sub UserForm_ToggleButton1_Click()
If UserForm_ToggleButton1.Value = True Then
UserForm_ToggleButton1.Caption = "Left Align"
UserForm_OptionButton1.Alignment = 0
UserForm_OptionButton2.Alignment = 0
Else
UserForm_ToggleButton1.Caption = "Right Align"
UserForm_OptionButton1.Alignment = 1
UserForm_OptionButton2.Alignment = 1
End If
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25