Freigeben über


TextBoxBase-Klasse

Implementiert die für Textsteuerelemente erforderlichen Grundfunktionen.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public MustInherit Class TextBoxBase
    Inherits Control
'Usage
Dim instance As TextBoxBase
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public abstract class TextBoxBase : Control
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class TextBoxBase abstract : public Control
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public abstract class TextBoxBase extends Control
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public abstract class TextBoxBase extends Control

Hinweise

Diese Klasse implementiert die Kernfeatures von Steuerelementen für die Textbearbeitung wie TextBox und RichTextBox. Dies beinhaltet die Textauswahl, die Funktionen der Zwischenablage, die Unterstützung von Steuerelementen für mehrzeiligen Text und viele Ereignisse.

Hinweise für Erben Üblicherweise wird von TextBoxBase nicht geerbt. Vererben Sie die TextBox-Klasse oder die RichTextBox-Klasse, um eine eigene Textsteuerelement-Klasse zu erstellen.

Beispiel

Im folgenden Codebeispiel wird mit der abgeleiteten Klasse TextBox ein mehrzeiliges TextBox-Steuerelement mit vertikalen Bildlaufleisten erstellt. In diesem Beispiel werden außerdem die Eigenschaften AcceptsTab, AcceptsReturn und WordWrap verwendet, damit das mehrzeilige Textfeld-Steuerelement sinnvoll zum Erstellen von Textdokumenten eingesetzt werden kann.

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

Vererbungshierarchie

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

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

TextBoxBase-Member
System.Windows.Forms-Namespace
TextBox-Klasse
RichTextBox-Klasse