Actualización: noviembre 2007
Implementa la funcionalidad básica requerida por controles de texto.
Ensamblado: System.Windows.Forms (en System.Windows.Forms.dll)
<DefaultBindingPropertyAttribute("Text")> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ <ComVisibleAttribute(True)> _ Public MustInherit Class TextBoxBase _ Inherits Control
Dim instance As TextBoxBase
[DefaultBindingPropertyAttribute("Text")] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] [ComVisibleAttribute(true)] public abstract class TextBoxBase : Control
[DefaultBindingPropertyAttribute(L"Text")] [ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] [ComVisibleAttribute(true)] public ref class TextBoxBase abstract : public Control
/** @attribute DefaultBindingPropertyAttribute("Text") */
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */
/** @attribute ComVisibleAttribute(true) */
public abstract class TextBoxBase extends Control
public abstract class TextBoxBase extends Control
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.
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.
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
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"; }
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"; }
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
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
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.