ScrollBars 和 KeepScrollBarsVisible 属性示例

下例用 ScrollBars 和 KeepScrollBarsVisible 属性,在框架中和多页控件的页面中添加滚动条。用户选中一个选项按钮,随后为 KeepScrollBarsVisible 指定一个值。

窗体包含:

  • 名为 MultiPage1 的多页控件。
  • 名为 Frame1 的框架。
  • 名为从 OptionButton1 到 OptionButton4 的四个选项按钮控件。
Sub UserForm_Initialize()
     UserForm_MultiPage1.Pages(0).ScrollBars = 3
     UserForm_MultiPage1.Pages(0).KeepScrollBarsVisible = 0
    
     UserForm_Frame1.ScrollBars = 3
     UserForm_Frame1.KeepScrollBarsVisible =  0
    
     UserForm_OptionButton1.Caption = "No scroll bars"
     UserForm_OptionButton1.Value = True
     UserForm_OptionButton2.Caption = "Horizontal scroll bars"
     UserForm_OptionButton3.Caption = "Vertical scroll bars"
     UserForm_OptionButton4.Caption = "Both scroll bars"
End Sub

Sub  UserForm_OptionButton1_Click()
     UserForm_MultiPage1.Pages(0).KeepScrollBarsVisible = 0
     UserForm_Frame1.KeepScrollBarsVisible = 0
End Sub

Sub  UserForm_OptionButton2_Click()
     UserForm_MultiPage1.Pages(0).KeepScrollBarsVisible = 1
    UserForm_Frame1.KeepScrollBarsVisible = 1
End Sub

Sub  UserForm_OptionButton3_Click()
     UserForm_MultiPage1.Pages(0).KeepScrollBarsVisible = 2
     UserForm_Frame1.KeepScrollBarsVisible = 2
End Sub

Sub  UserForm_OptionButton4_Click()
     UserForm_MultiPage1.Pages(0).KeepScrollBarsVisible = 3
     UserForm_Frame1.KeepScrollBarsVisible = 3
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
31
32
33