Freigeben über


TextBox.AcceptsReturn-Eigenschaft

Ruft einen Wert ab, der angibt, ob in einem mehrzeiligen TextBox-Steuerelement beim Drücken der EINGABETASTE eine neue Textzeile begonnen oder die Standardschaltfläche des Formulars aktiviert wird, oder legt diesen fest.

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

Syntax

'Declaration
Public Property AcceptsReturn As Boolean
'Usage
Dim instance As TextBox
Dim value As Boolean

value = instance.AcceptsReturn

instance.AcceptsReturn = value
public bool AcceptsReturn { get; set; }
public:
property bool AcceptsReturn {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_AcceptsReturn ()

/** @property */
public void set_AcceptsReturn (boolean value)
public function get AcceptsReturn () : boolean

public function set AcceptsReturn (value : boolean)

Eigenschaftenwert

true, wenn mit der EINGABETASTE eine neue Textzeile in einer mehrzeiligen Version des Steuerelements erstellt wird. false, wenn mit der EINGABETASTE die Standardschaltfläche des Formulars aktiviert wird. Der Standardwert ist false.

Hinweise

Wenn der Wert für die Eigenschaft false ist, muss der Benutzer STRG+EINGABETASTE drücken, um eine neue Zeile in einem mehrzeiligen TextBox-Steuerelement zu erstellen. Wenn das Formular über keine Standardschaltfläche verfügt, wird unabhängig vom Wert dieser Eigenschaft mit der EINGABETASTE immer eine neue Textzeile im Steuerelement erstellt.

Hinweis zu Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows CE: Sie können diese Eigenschaft zwar auf false festlegen, doch verhält sie sich immer, als wenn sie auf true wäre. Wenn eine bestimmte Schaltfläche mit der EINGABETASTE aktiviert werden soll, können Sie eine Klasse von TextBox ableiten und für das Eintreten des KeyPress-Ereignisses Ereignishandlercode für die EINGABETASTE bereitstellen.

Beispiel

Im folgenden Codebeispiel wird ein mehrzeiliges TextBox-Steuerelement mit vertikalen Bildlaufleisten erstellt. In diesem Beispiel werden die Eigenschaften AcceptsTab, AcceptsReturn und WordWrap verwendet, um das mehrzeilige Textfeld-Steuerelement zum Erstellen von Textdokumenten verwenden zu können.

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 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
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 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!";
 }
 
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 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!";
   }
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 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
public function CreateMyMultilineTextBox()
 {
    // Create an instance of a TextBox control.
    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 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!";
 }
 

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

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