Panel.ScrollBars Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the visibility and position of scroll bars in a Panel control.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

abstract ScrollBars : ScrollBars with get, set
override ScrollBars : ScrollBars with get, set

Property Value

Type: System.Web.UI.WebControls.ScrollBars

One of the ScrollBars enumeration values. The default is None.

Use the ScrollBars property to specify the visibility and position of scroll bars in a Panel control. This 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.

If you specify Auto for the ScrollBars property, scroll bars are automatically shown when the size of the content in a Panel control exceeds the size of the Panel control itself. For example, if a Panel control contains a table, and the panel is not wide enough to display all the rows in the table, a vertical scroll bar is shown. If the size of the table exceeds the height and width of the panel, both vertical and horizontal scroll bars are shown.

System_CAPS_noteNote

This property is supported only on browsers that support HTML 4.0 or later.

The following code example demonstrates how to declaratively set the ScrollBars property to Auto. The panel contains a table, the entire contents of which exceed the size of the panel. This causes both vertical and horizontal scroll bars to be automatically displayed when the panel is rendered. The user can then scroll to view all the data in the table.

System_CAPS_noteNote

The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see ASP.NET Web Forms Page Code Model.

No code example is currently available or this language may not be supported.

The following code example demonstrates how to programmatically set the ScrollBars property. A ListBox control is populated with the ScrollBars enumeration values. The scroll bars displayed in the panel change, based on the value the user selects from the list box.

System_CAPS_noteNote

The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see ASP.NET Web Forms Page Code Model.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: