TextBox.AcceptsReturn Vlastnost

Definice

Získá nebo nastaví hodnotu určující, zda stisknutí klávesy ENTER ve víceřádkovém TextBox ovládacím prvku vytvoří nový řádek textu v ovládacím prvku nebo aktivuje výchozí tlačítko formuláře.

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

Hodnota vlastnosti

true pokud klávesa ENTER vytvoří nový řádek textu ve víceřádkové verzi ovládacího prvku; false pokud klávesa ENTER aktivuje výchozí tlačítko formuláře. Výchozí hodnota je false.

Příklady

Následující příklad kódu vytvoří víceřádkový TextBox ovládací prvek se svislými posuvníky. Tento příklad používá AcceptsTab, AcceptsReturna WordWrap vlastnosti, aby víceřádkové textové pole ovládací prvek užitečné pro vytváření textových dokumentů.

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

Poznámky

Pokud je falsehodnota této vlastnosti, musí uživatel stisknutím kombinace kláves CTRL+ENTER vytvořit nový řádek ve víceřádkovém TextBox ovládacím prvku. Pokud formulář nemá žádné výchozí tlačítko, klávesa ENTER vždy vytvoří nový řádek textu v ovládacím prvku bez ohledu na hodnotu této vlastnosti.

Platí pro