TextBoxBase-Klasse
Aktualisiert: November 2007
Implementiert die für Textsteuerelemente erforderlichen Grundfunktionen.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
[DefaultBindingPropertyAttribute("Text")] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] [ComVisibleAttribute(true)] public abstract class TextBoxBase : Control
/** @attribute DefaultBindingPropertyAttribute("Text") */
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */
/** @attribute ComVisibleAttribute(true) */
public abstract class TextBoxBase extends Control
public abstract class TextBoxBase extends Control
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 zur Vererbung:Üblicherweise wird von TextBoxBase nicht geerbt. Vererben Sie die TextBox-Klasse oder die RichTextBox-Klasse, um eine eigene Textsteuerelement-Klasse zu erstellen.
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 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 = 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
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 für Smartphone, Windows Mobile für Pocket PC
.NET Framework und .NET Compact Framework unterstützen nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.