PanelStyle.ScrollBars 属性

定义

获取或设置面板控件中滚动条的可见性和位置。Gets or sets the visibility and position of scroll bars in a panel control.

public:
 virtual property System::Web::UI::WebControls::ScrollBars ScrollBars { System::Web::UI::WebControls::ScrollBars get(); void set(System::Web::UI::WebControls::ScrollBars value); };
public virtual System.Web.UI.WebControls.ScrollBars ScrollBars { get; set; }
member this.ScrollBars : System.Web.UI.WebControls.ScrollBars with get, set
Public Overridable Property ScrollBars As ScrollBars

属性值

ScrollBars

ScrollBars 值之一。One of the ScrollBars values. 默认值为 NoneThe default is None.

例外

ScrollBars 属性不是 ScrollBars 值中的其中一个。The ScrollBars property is not one of the ScrollBars values.

示例

下面的代码示例将 ScrollBars 两个 panel 控件的属性 Panel1 和设置 Panel2ScrollBars.Both 枚举值。The following code example sets the ScrollBars properties of two panel controls, Panel1 and Panel2, to the ScrollBars.Both enumeration value. 此代码示例是为类提供的更大示例的一部分 PanelStyleThis code example is part of a larger example provided for the PanelStyle class.

public partial class PanelStylecs_aspx : Page
{
    void Page_Load(object sender, EventArgs e)
    {
        StateBag panelState = new StateBag();
        PanelStyle myPanelStyle = new PanelStyle(panelState);
        
        // Set the properties of the PanelStyle class.
        myPanelStyle.HorizontalAlign = HorizontalAlign.Center;
        myPanelStyle.ScrollBars = ScrollBars.Both;
        myPanelStyle.Wrap = false;
        myPanelStyle.Direction = ContentDirection.LeftToRight;
        myPanelStyle.BackImageUrl = @"~\images\picture.jpg";

        // Use the ApplyStyle method of the Panel control to apply
        // the settings from the myPanelStyle object.
        Panel1.ApplyStyle(myPanelStyle);
        Panel2.ApplyStyle(myPanelStyle); 
    }
}
Partial Class PanelStylevb_aspx
    Inherits Page

    Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        Dim panelState As StateBag = New StateBag()
        Dim myPanelStyle As PanelStyle = New PanelStyle(panelState)

        ' Set the properties of the PanelStyle class.
        myPanelStyle.HorizontalAlign = HorizontalAlign.Center
        myPanelStyle.ScrollBars = ScrollBars.Both
        myPanelStyle.Wrap = False
        myPanelStyle.Direction = ContentDirection.LeftToRight
        myPanelStyle.BackImageUrl = "~\images\picture.jpg"

        ' Use the ApplyStyle method of the Panel control to apply
        ' the settings from the myPanelStyle object.
        Panel1.ApplyStyle(myPanelStyle)
        Panel2.ApplyStyle(myPanelStyle)
        
    End Sub

End Class

注解

ScrollBars属性指定面板控件中滚动条的可见性和位置。The ScrollBars property specifies the visibility and position of scroll bars in a panel control.

ScrollBars使用枚举值之一设置属性 ScrollBarsThe ScrollBars property is set using one of the ScrollBars enumeration values. 下表列出了可能的值。The following table lists the possible values.

Value 说明Description
None 不显示任何滚动条。No scroll bars are shown.
Horizontal 只显示水平滚动条。Only a horizontal scroll bar is shown.
Vertical 只显示垂直滚动条。Only a vertical scroll bar is shown.
Both 同时显示水平滚动条和垂直滚动条。Both horizontal and vertical scroll bars are shown.
Auto 如有必要,将显示水平、垂直或同时显示这两个滚动条。If necessary, horizontal, vertical, or both scroll bars are shown. 要不然也可以不显示任何滚动条。Otherwise, no scroll bars are shown.

适用于

另请参阅