Exportar (0) Imprimir
Expandir todo
Expandir Minimizar

ScrollBars (Enumeración)

Especifica qué barras de desplazamiento serán visibles en un control.

Espacio de nombres: System.Windows.Forms
Ensamblado: System.Windows.Forms (en system.windows.forms.dll)

public enum ScrollBars
public enum ScrollBars
public enum ScrollBars

 Nombre de miembroDescripción
Compatible con .NET Compact FrameworkBothSe muestran las barras de desplazamiento horizontal y vertical. 
Compatible con .NET Compact FrameworkHorizontalSe muestran sólo las barras de desplazamiento horizontal. 
Compatible con .NET Compact FrameworkNoneNo se muestra ninguna barra de desplazamiento. 
Compatible con .NET Compact FrameworkVerticalSe muestran sólo las barras de desplazamiento vertical. 

TextBox.ScrollBars utiliza esta enumeración.

No todos los controles admiten barras de desplazamiento. Utilice esta enumeración para especificar qué barras de desplazamiento serán visibles en un control, en todas o en algunas circunstancias.

El ejemplo de código siguiente muestra cómo utilizar la enumeración ScrollBars.Para ejecutar el ejemplo, pegue el código siguiente en un formulario. Llame al método SetFourDifferentScrollBars en el constructor del formulario o en el método de control de eventos Load.


// Declare four textboxes.
internal System.Windows.Forms.TextBox vertical;
internal System.Windows.Forms.TextBox horizontal;
internal System.Windows.Forms.TextBox both;
internal System.Windows.Forms.TextBox none;

private void SetFourDifferentScrollBars()
{
    
    this.vertical = new System.Windows.Forms.TextBox();
    this.horizontal = new System.Windows.Forms.TextBox();
    this.both = new System.Windows.Forms.TextBox();
    this.none = new System.Windows.Forms.TextBox();

    // Create a string for the Text property.
    string startString = "The scroll bar style for my textbox is: ";

    // Set the location of the four textboxes.
    horizontal.Location = new Point(10, 10);
    vertical.Location = new Point(10, 70);
    none.Location = new Point(10, 170);
    both.Location = new Point(10, 110);

    // For horizonal scroll bars, the Multiline property must
    // be true and the WordWrap property must be false.
    // Increase the size of the Height property to ensure the 
    // scroll bar is visible.
    horizontal.ScrollBars = ScrollBars.Horizontal;
    horizontal.Multiline = true;
    horizontal.WordWrap = false;
    horizontal.Height = 40;
    horizontal.Text = startString + 
        ScrollBars.Horizontal.ToString();

    // For the vertical scroll bar, Multiline must be true.
    vertical.ScrollBars = ScrollBars.Vertical;
    vertical.Multiline = true;
    vertical.Text = startString + ScrollBars.Vertical.ToString();

    // For both scroll bars, the Multiline property 
    // must be true, and the WordWrap property must be false.
    // Increase the size of the Height property to ensure the 
    // scroll bar is visible.
    both.ScrollBars = ScrollBars.Both;
    both.Multiline = true;
    both.WordWrap = false;
    both.Height = 40;
    both.AcceptsReturn = true;
    both.Text = startString + ScrollBars.Both.ToString();

    // The none scroll bar does not require specific 
    // property settings.
    none.ScrollBars = ScrollBars.None;
    none.Text = startString + ScrollBars.None.ToString();

    // Add the textboxes to the form.
    this.Controls.Add(this.vertical);
    this.Controls.Add(this.horizontal);
    this.Controls.Add(this.both);
    this.Controls.Add(this.none);

}

// Declare four textboxes.
System.Windows.Forms.TextBox vertical;
System.Windows.Forms.TextBox horizontal;
System.Windows.Forms.TextBox both;
System.Windows.Forms.TextBox none;

private void SetFourDifferentScrollBars()
{
    this.vertical = new System.Windows.Forms.TextBox();
    this.horizontal = new System.Windows.Forms.TextBox();
    this.both = new System.Windows.Forms.TextBox();
    this.none = new System.Windows.Forms.TextBox();
    // Create a string for the Text property.
    String startString = "The scroll bar style for my textbox is: ";
    // Set the location of the four textboxes.
    horizontal.set_Location(new Point(10, 10));
    vertical.set_Location(new Point(10, 70));
    none.set_Location(new Point(10, 170));
    both.set_Location(new Point(10, 110));
    // For horizonal scroll bars, the Multiline property must
    // be true and the WordWrap property must be false.
    // Increase the size of the Height property to ensure the 
    // scroll bar is visible.
    horizontal.set_ScrollBars(ScrollBars.Horizontal);
    horizontal.set_Multiline(true);
    horizontal.set_WordWrap(false);
    horizontal.set_Height(40);
    horizontal.set_Text(startString + ScrollBars.Horizontal.ToString());
    // For the vertical scroll bar, Multiline must be true.
    vertical.set_ScrollBars(ScrollBars.Vertical);
    vertical.set_Multiline(true);
    vertical.set_Text(startString + ScrollBars.Vertical.ToString());
    // For both scroll bars, the Multiline property 
    // must be true, and the WordWrap property must be false.
    // Increase the size of the Height property to ensure the 
    // scroll bar is visible.
    both.set_ScrollBars(ScrollBars.Both);
    both.set_Multiline(true);
    both.set_WordWrap(false);
    both.set_Height(40);
    both.set_AcceptsReturn(true);
    both.set_Text(startString + ScrollBars.Both.ToString());
    // The none scroll bar does not require specific 
    // property settings.
    none.set_ScrollBars(ScrollBars.None);
    none.set_Text(startString + ScrollBars.None.ToString());
    // Add the textboxes to the form.
    this.get_Controls().Add(this.vertical);
    this.get_Controls().Add(this.horizontal);
    this.get_Controls().Add(this.both);
    this.get_Controls().Add(this.none);
} //SetFourDifferentScrollBars 

Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter

Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

.NET Framework

Compatible con: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Compatible con: 2.0, 1.0
Mostrar:
© 2014 Microsoft