TextBoxBase (Clase) (System.Windows.Forms)

Cambiar vista:
Sin script
Biblioteca de clases de .NET Framework
TextBoxBase (Clase)

Actualización: noviembre 2007

Implementa la funcionalidad básica requerida por controles de texto.

Espacio de nombres:  System.Windows.Forms
Ensamblado:  System.Windows.Forms (en System.Windows.Forms.dll)
Sintaxis

Visual Basic (Declaración)
<DefaultBindingPropertyAttribute("Text")> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public MustInherit Class TextBoxBase _
	Inherits Control
Visual Basic (Uso)
Dim instance As TextBoxBase
C#
[DefaultBindingPropertyAttribute("Text")]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[ComVisibleAttribute(true)]
public abstract class TextBoxBase : Control
Visual C++
[DefaultBindingPropertyAttribute(L"Text")]
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
[ComVisibleAttribute(true)]
public ref class TextBoxBase abstract : public Control
J#
/** @attribute DefaultBindingPropertyAttribute("Text") */
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */
/** @attribute ComVisibleAttribute(true) */
public abstract class TextBoxBase extends Control
JScript
public abstract class TextBoxBase extends Control
Comentarios

Esta clase implementa las características principales de los controles de manipulación de texto, como TextBox y RichTextBox. Estas características incluyen la selección de texto, la funcionalidad de Portapapeles, la compatibilidad con controles de texto multilínea y numerosos eventos.

Notas para los herederos:

Habitualmente no se hereda de TextBoxBase. Para crear su propia clase de control de texto, debe heredar de TextBox o de RichTextBox.

Ejemplos

En el siguiente ejemplo de código se utiliza TextBox, una clase derivada, con el fin de crear un control TextBox multilínea con barras de desplazamiento verticales. En este ejemplo también se emplean las propiedades AcceptsTab, AcceptsReturn y WordWrap con el fin de hacer que el control de cuadro de texto multilínea resulte ú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 RETURN key 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!" & Environment.NewLine & "Second Line"
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 RETURN key 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!" + Environment.NewLine + "Second Line";
 }


Visual 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 RETURN key 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!" + Environment::NewLine + "Second Line";
   }


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 RETURN key 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!" + Environment.get_NewLine()
        + "Second Line");
} //CreateMyMultilineTextBox


Jerarquía de herencia

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      System.Windows.Forms.Control
        System.Windows.Forms.TextBoxBase
          System.Windows.Forms.MaskedTextBox
          System.Windows.Forms.RichTextBox
          System.Windows.Forms.TextBox
Seguridad para subprocesos

Todos los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.
Plataformas

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile para Smartphone, Windows Mobile para Pocket PC

.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
Información de versión

.NET Framework

Compatible con: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Compatible con: 3.5, 2.0, 1.0
Vea también

Referencia