TextBox.AcceptsReturn Właściwość

Definicja

Pobiera lub ustawia wartość wskazującą, czy naciśnięcie klawisza ENTER w kontrolce wielowierszowej TextBox tworzy nowy wiersz tekstu w kontrolce lub aktywuje przycisk domyślny formularza.

public:
 property bool AcceptsReturn { bool get(); void set(bool value); };
public bool AcceptsReturn { get; set; }
member this.AcceptsReturn : bool with get, set
Public Property AcceptsReturn As Boolean

Wartość właściwości

Boolean

true jeśli klawisz ENTER tworzy nowy wiersz tekstu w wielowierszowej wersji kontrolki; false jeśli klucz ENTER aktywuje przycisk domyślny formularza. Wartość domyślna to false.

Przykłady

Poniższy przykład kodu tworzy kontrolkę wielowierszową TextBox z pionowymi paskami przewijania. W tym przykładzie użyto AcceptsTabwłaściwości , AcceptsReturni WordWrap , aby kontrolka wielowierszowego pola tekstowego przydała się do tworzenia dokumentów tekstowych.

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.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 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

Uwagi

Jeśli wartość tej właściwości to false, użytkownik musi nacisnąć klawisze CTRL+ENTER, aby utworzyć nowy wiersz w kontrolce wielowierszowej TextBox . Jeśli formularz nie ma przycisku domyślnego, klucz ENTER zawsze utworzy nowy wiersz tekstu w kontrolce, niezależnie od wartości tej właściwości.

Dotyczy