Panel::ScrollBars Property
Gets or sets the visibility and position of scroll bars in a Panel control.
Assembly: System.Web (in System.Web.dll)
public: virtual property ScrollBars ScrollBars { ScrollBars get (); void set (ScrollBars value); }
<asp:Panel ScrollBars="ScrollBars" />
Property Value
Type: System.Web.UI.WebControls::ScrollBarsOne 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.
Note |
|---|
This property is supported only on browsers that support HTML 4.0 or later. |
| Topic | Location |
|---|---|
| How to: Add Panel Web Server Controls to a Web Forms Page | Building ASP .NET Web Applications |
| How to: Add Panel Web Server Controls to a Web Forms Page | Building ASP .NET Web Applications |
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.
Note |
|---|
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 Page Code Model. |
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.
Note |
|---|
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 Page Code Model. |
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note