ScrollBars、KeepScrollBarsVisible 属性示例ScrollBars, KeepScrollBarsVisible properties example

下面的示例使用**滚动** 条和**KeepScrollBarsVisible** 属性将滚动条添加到**** 页页面和**** 中的页面。The following example uses the ScrollBars and the KeepScrollBarsVisible properties to add scroll bars to a page of a MultiPage and to a Frame. 用户选择了一个选项按钮,该按钮反过来指定 KeepScrollBarsVisible 的值。The user chooses an option button that, in turn, specifies a value for KeepScrollBarsVisible.

若要使用此示例,请将此示例代码复制到窗体的声明部分。To use this example, copy this sample code to the Declarations portion of a form. 确保该窗体包含:Make sure that the form contains:

  • 一个名为"MultiPage1"的 MultiPageA MultiPage named MultiPage1.
  • 一个名为"Frame1"的 FrameA Frame named Frame1.
  • 四个名称分别为"OptionButton1"到"OptionButton4"的 OptionButton 控件。Four OptionButton controls named OptionButton1 through OptionButton4.
Private Sub UserForm_Initialize() 
 MultiPage1.Pages(0).ScrollBars = fmScrollBarsBoth 
 MultiPage1.Pages(0).KeepScrollBarsVisible = fmScrollBarsNone 
 
 Frame1.ScrollBars = fmScrollBarsBoth 
 Frame1.KeepScrollBarsVisible = fmScrollBarsNone 
 
 OptionButton1.Caption = "No scroll bars" 
 OptionButton1.Value = True 
 OptionButton2.Caption = "Horizontal scroll bars" 
 OptionButton3.Caption = "Vertical scroll bars" 
 OptionButton4.Caption = "Both scroll bars" 
End Sub 
 
Private Sub OptionButton1_Click() 
 MultiPage1.Pages(0).KeepScrollBarsVisible = _ 
 fmScrollBarsNone 
 Frame1.KeepScrollBarsVisible = fmScrollBarsNone 
End Sub 
 
Private Sub OptionButton2_Click() 
 MultiPage1.Pages(0).KeepScrollBarsVisible = _ 
 fmScrollBarsHorizontal 
 Frame1.KeepScrollBarsVisible = _ 
 fmScrollBarsHorizontal 
End Sub 
 
Private Sub OptionButton3_Click() 
 MultiPage1.Pages(0).KeepScrollBarsVisible = _ 
 fmScrollBarsVertical 
 Frame1.KeepScrollBarsVisible = _ 
 fmScrollBarsVertical 
End Sub 
 
Private Sub OptionButton4_Click() 
 MultiPage1.Pages(0).KeepScrollBarsVisible = _ 
 fmScrollBarsBoth 
 Frame1.KeepScrollBarsVisible = fmScrollBarsBoth 
End Sub

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.