TextBox.ScrollBars (Propiedad)
Obtiene o establece qué barras de desplazamiento tienen que aparecer en un control TextBox multilínea.

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

Sintaxis

Visual Basic (Declaración)
<LocalizableAttribute(True)> _
Public Property ScrollBars As ScrollBars
Visual Basic (Uso)
Dim instance As TextBox
Dim value As ScrollBars

value = instance.ScrollBars

instance.ScrollBars = value
C#
[LocalizableAttribute(true)] 
public ScrollBars ScrollBars { get; set; }
C++
[LocalizableAttribute(true)] 
public:
property ScrollBars ScrollBars {
    ScrollBars get ();
    void set (ScrollBars value);
}
J#
/** @property */
public ScrollBars get_ScrollBars ()

/** @property */
public void set_ScrollBars (ScrollBars value)
JScript
public function get ScrollBars () : ScrollBars

public function set ScrollBars (value : ScrollBars)
XAML
No aplicable.

Valor de propiedad

Uno de los valores de enumeración de ScrollBars que indica si un control TextBox de varias líneas aparece sin barras de desplazamiento, con una barra de desplazamiento horizontal, con una barra de desplazamiento vertical o con las dos. El valor predeterminado es ScrollBars.None.
Excepciones

Tipo de excepciónCondición

InvalidEnumArgumentException

Se asignó a la propiedad un valor no situado dentro del intervalo de valores permitidos para la enumeración.

Comentarios

Las barras de desplazamiento horizontales no se mostrarán si la propiedad WordWrap se establece en true, independientemente del valor de la propiedad ScrollBars.

Ejemplo

En el siguiente ejemplo de código se crea un control TextBox multilínea con barras de desplazamiento verticales. En este ejemplo también se utilizan las propiedades AcceptsTab, AcceptsReturn y WordWrap para hacer que el control TextBox multilínea sea útil para crear documentos de texto.

Visual Basic
Public Sub CreateMyMultilineTextBox()
    ' Create an instance of a TextBox control.
    Dim textBox1 As New TextBox()
    
    ' Set the Multiline property to true.
    textBox1.Multiline = True
    ' Add vertical scroll bars to the TextBox control.
    textBox1.ScrollBars = ScrollBars.Vertical
    ' Allow the TAB key to be entered in the TextBox control.
    textBox1.AcceptsReturn = True
    ' Allow the TAB key to be entered in the TextBox control.
    textBox1.AcceptsTab = True
    ' Set WordWrap to true to allow text to wrap to the next line.
    textBox1.WordWrap = True
    ' Set the default text of the control.
    textBox1.Text = "Welcome!"
End Sub
C#
public void CreateMyMultilineTextBox()
{
    // Create an instance of a TextBox control.
    TextBox textBox1 = new TextBox();
    
    // Set the Multiline property to true.
    textBox1.Multiline = true;
    // Add vertical scroll bars to the TextBox control.
    textBox1.ScrollBars = ScrollBars.Vertical;
    // Allow the TAB key to be entered in the TextBox control.
    textBox1.AcceptsReturn = true;
    // Allow the TAB key to be entered in the TextBox control.
    textBox1.AcceptsTab = true;
    // Set WordWrap to true to allow text to wrap to the next line.
    textBox1.WordWrap = true;
    // Set the default text of the control.
    textBox1.Text = "Welcome!";
 }
 
C++
public:
   void CreateMyMultilineTextBox()
   {
      // Create an instance of a TextBox control.
      TextBox^ textBox1 = gcnew TextBox;
      
      // Set the Multiline property to true.
      textBox1->Multiline = true;
      // Add vertical scroll bars to the TextBox control.
      textBox1->ScrollBars = ScrollBars::Vertical;
      // Allow the TAB key to be entered in the TextBox control.
      textBox1->AcceptsReturn = true;
      // Allow the TAB key to be entered in the TextBox control.
      textBox1->AcceptsTab = true;
      // Set WordWrap to true to allow text to wrap to the next line.
      textBox1->WordWrap = true;
      // Set the default text of the control.
      textBox1->Text = "Welcome!";
   }
J#
public void CreateMyMultilineTextBox()
{
    // Create an instance of a TextBox control.
    TextBox textBox1 = new TextBox();
    // Set the Multiline property to true.
    textBox1.set_Multiline(true);
    // Add vertical scroll bars to the TextBox control.
    textBox1.set_ScrollBars(ScrollBars.Vertical);
    // Allow the TAB key to be entered in the TextBox control.
    textBox1.set_AcceptsReturn(true);
    // Allow the TAB key to be entered in the TextBox control.
    textBox1.set_AcceptsTab(true);
    // Set WordWrap to true to allow text to wrap to the next line.
    textBox1.set_WordWrap(true);
    // Set the default text of the control.
    textBox1.set_Text("Welcome!");
} //CreateMyMultilineTextBox
Plataformas

Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, 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.

Información de versión

.NET Framework

Compatible con: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Compatible con: 2.0, 1.0
Vea también

Page view tracker