ScrollBars ScrollBars ScrollBars ScrollBars Enum

Definizione

Specifica la visibilità e la posizione delle barre di scorrimento in un controllo Panel.Specifies the visibility and position of scroll bars in a Panel control.

Questa enumerazione ha un attributo FlagsAttribute che consente una combinazione bit per bit dei valori del relativo membro.

public enum class ScrollBars
[System.Flags]
public enum ScrollBars
type ScrollBars = 
Public Enum ScrollBars
Ereditarietà
Attributi

Campi

Auto Auto Auto Auto 4

Visualizza, se necessario, barre di scorrimento orizzontali, verticali o entrambe.Displays, horizontal, vertical, or both scroll bars as necessary. In caso contrario, non viene visualizzata alcuna barra di scorrimento.Otherwise, no scroll bars are shown.

Both Both Both Both 3

Visualizza sia una barra di scorrimento orizzontale, sia una barra di scorrimento verticale.Displays both a horizontal and a vertical scroll bar.

Horizontal Horizontal Horizontal Horizontal 1

Visualizza soltanto una barra di scorrimento orizzontale.Displays only a horizontal scroll bar.

None None None None 0

Non visualizza alcuna barra di scorrimento.Displays no scroll bars.

Vertical Vertical Vertical Vertical 2

Visualizza soltanto una barra di scorrimento verticale.Displays only a vertical scroll bar.

Esempi

Nell'esempio di codice riportato di seguito viene illustrato come impostare ScrollBars in modo Autodichiarativo la proprietà su.The following code example demonstrates how to declaratively set the ScrollBars property to Auto. Il pannello contiene una tabella, l'intero contenuto di che supera le dimensioni del pannello.The panel contains a table, the entire contents of which exceed the size of the panel. In questo modo vengono visualizzate automaticamente le barre di scorrimento verticali e orizzontali quando viene eseguito il rendering del pannello.This causes both vertical and horizontal scroll bars to be automatically displayed when the panel is rendered. L'utente può quindi scorrere per visualizzare tutti i dati nella tabella.The user can then scroll to view all the data in the table.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    private void Page_Load(object sender, EventArgs e)
    {
        // Add more rows and columns to the table than can
        // be displayed in the panel area.
        // Scroll bars will be required to view all the data.

        // Add rows and columns to the table.
        for (int rowNum = 0; rowNum < 51; rowNum++)
        {
            TableRow tempRow = new TableRow();
            for (int cellNum = 0; cellNum < 11; cellNum++)
            {
                TableCell tempCell = new TableCell();
                tempCell.Text = 
                    String.Format("({0}, {1})", rowNum, cellNum);
                tempRow.Cells.Add(tempCell);
            }
            Table1.Rows.Add(tempRow);
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title>Panel Scrollbars - C# Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h3>Panel.ScrollBars Property Example</h3>        

    <asp:Panel ID="Panel1" runat="Server"
      Height="300px" Width="400px"
      BackColor="Aqua" ScrollBars="Auto">

      <asp:Table ID="Table1" runat="Server"></asp:Table>  

    </asp:Panel>         

    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    Private Sub Page_Load(ByVal sender As Object, _
        ByVal e As System.EventArgs)

        ' Add more rows and columns to the table than can
        ' be displayed in the panel area.
        ' Scroll bars will be required to view all the data.

        ' Add rows and columns to the table.
        Dim rowNum As Integer
        For rowNum = 0 To 50
            Dim tempRow As New TableRow
            Dim cellNum As Integer
            For cellNum = 0 To 10
                Dim tempCell As New TableCell
                tempCell.Text = _
                    String.Format("({0}, {1})", rowNum, cellNum)
                tempRow.Cells.Add(tempCell)
            Next
            Table1.Rows.Add(tempRow)
        Next
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title>Panel Scrollbars - VB.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h3>Panel.ScrollBars Property Example</h3>        

    <asp:Panel ID="Panel1" runat="Server"
      Height="300px" Width="400px"
      BackColor="Aqua" ScrollBars="Auto">

      <asp:Table ID="Table1" runat="Server"></asp:Table>  

    </asp:Panel>         

    </div>
    </form>
</body>
</html>

Nell'esempio di codice riportato di ScrollBars seguito vengono illustrati i valori di enumerazione.The following code example demonstrates the ScrollBars enumeration values. Un ListBox controllo viene popolato con ScrollBars i valori di enumerazione.A ListBox control is populated with the ScrollBars enumeration values. Le barre di scorrimento visualizzate nel pannello cambiano in base al valore selezionato dall'utente dalla casella di riepilogo.The scroll bars displayed in the panel change, based on the value the user selects from the list box.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    private void Page_Load(object sender, EventArgs e)
    {
        // Add more rows and columns to the table than can
        // be displayed in the panel area.
        // Scroll bars will be required to view all the data.

        // Add rows and columns to the table.
        for (int rowNum = 0; rowNum < 51; rowNum++)
        {
            TableRow tempRow = new TableRow();
            for (int cellNum = 0; cellNum < 11; cellNum++)
            {
                TableCell tempCell = new TableCell();
                tempCell.Text = 
                    String.Format("({0}, {1})", rowNum, cellNum);
                tempRow.Cells.Add(tempCell);
            }
            Table1.Rows.Add(tempRow);
        }
    }

    private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        // Determine which list item was clicked.
        // Display the selected scroll bars in the panel.
        switch (ListBox1.SelectedIndex)
        {
            case 0:
                Panel1.ScrollBars = ScrollBars.None;
                break;
            case 1:
                Panel1.ScrollBars = ScrollBars.Horizontal;
                break;
            case 2:
                Panel1.ScrollBars = ScrollBars.Vertical;
                break;
            case 3:
                Panel1.ScrollBars = ScrollBars.Both;
                break;
            case 4:
                Panel1.ScrollBars = ScrollBars.Auto;
                break;
            default:
                throw new Exception("Select a valid list item.");
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h3>Panel.ScrollBars Property Example</h3>

    <h4>Select the scrollbars to display in the panel.</h4>
    <asp:ListBox ID="ListBox1" runat="Server"
      Rows="5" AutoPostBack="True"
      SelectionMode="Single"
      OnSelectedIndexChanged="ListBox1_SelectedIndexChanged">
      <asp:ListItem>None</asp:ListItem>
      <asp:ListItem>Horizontal</asp:ListItem> 
      <asp:ListItem>Vertical</asp:ListItem>
      <asp:ListItem>Both</asp:ListItem> 
      <asp:ListItem>Auto</asp:ListItem>              
    </asp:ListBox>

    <hr />              

    <asp:Panel ID="Panel1" runat="Server"
      Height="300px" Width="400px" BackColor="Aqua">
      <asp:Table ID="Table1" runat="Server" />
    </asp:Panel>           
         
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    Private Sub Page_Load(ByVal sender As Object, _
        ByVal e As System.EventArgs)

        ' Add more rows and columns to the table than can
        ' be displayed in the panel area.
        ' Scroll bars will be required to view all the data.

        ' Add rows and columns to the table.
        Dim i As Integer
        For i = 0 To 50
            Dim tempRow As New TableRow
            Dim j As Integer
            For j = 0 To 10
                Dim tempCell As New TableCell
                tempCell.Text = "(" & i & "," & j & ")"
                tempRow.Cells.Add(tempCell)
            Next j
            Table1.Rows.Add(tempRow)
        Next i
    End Sub

    Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, _
        ByVal e As EventArgs)

        ' Determine which list item was clicked.
        ' Display the selected scroll bars in the panel.
        Select Case (ListBox1.SelectedIndex)
            Case 0
                Panel1.ScrollBars = ScrollBars.None
            Case 1
                Panel1.ScrollBars = ScrollBars.Horizontal
            Case 2
                Panel1.ScrollBars = ScrollBars.Vertical
            Case 3
                Panel1.ScrollBars = ScrollBars.Both
            Case 4
                Panel1.ScrollBars = ScrollBars.Auto
            Case Else
                Throw New Exception("Select a valid list item.")
        End Select

    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h3>Panel.ScrollBars Property Example</h3>

    <h4>Select the scrollbars to display in the panel.</h4>
    <asp:ListBox ID="ListBox1" runat="Server"
      Rows="5" AutoPostBack="True" SelectionMode="Single"
      OnSelectedIndexChanged="ListBox1_SelectedIndexChanged">
      <asp:ListItem>None</asp:ListItem>
      <asp:ListItem>Horizontal</asp:ListItem> 
      <asp:ListItem>Vertical</asp:ListItem>
      <asp:ListItem>Both</asp:ListItem> 
      <asp:ListItem>Auto</asp:ListItem>              
    </asp:ListBox>

    <hr />              

    <asp:Panel ID="Panel1" runat="Server"
      Height="300px" Width="400px" BackColor="Aqua">
      <asp:Table ID="Table1" runat="Server" />
    </asp:Panel>           
         
    </div>
    </form>
</body>
</html>

Commenti

L' ScrollBars enumerazione rappresenta la visibilità e la posizione delle barre di scorrimento in Panel un controllo.The ScrollBars enumeration represents the visibility and position of the scroll bars in a Panel control. La ScrollBars proprietà utilizza questi valori di enumerazione per specificare il tipo di barre di scorrimento da visualizzare Panel in un controllo.The ScrollBars property uses these enumeration values to specify the type of scroll bars to display in a Panel control. Il valore predefinito per la ScrollBars proprietà è None, a indicare che non viene visualizzata alcuna barra di scorrimento.The default value for the ScrollBars property is None, indicating that no scroll bars are shown.

Se si specifica Auto per la ScrollBars proprietà, le barre di scorrimento vengono visualizzate automaticamente quando la dimensione del contenuto di Panel un controllo supera le dimensioni del Panel controllo.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. Se, ad esempio, Panel un controllo contiene una tabella e il pannello non è sufficientemente ampio per visualizzare tutte le righe della tabella, viene visualizzata una barra di scorrimento verticale.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. Se la dimensione della tabella supera l'altezza e la larghezza del pannello, vengono visualizzate le barre di scorrimento verticali e orizzontali.If the size of the table exceeds the height and width of the panel, both vertical and horizontal scroll bars are shown.

Si applica a

Vedi anche