TextBox.AcceptsReturn プロパティ

定義

複数行 TextBox コントロールで Enter キーを押すと、コントロールでテキストを改行するのか、またはフォームの既定のボタンをアクティブにするのかを示す値を取得または設定します。

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

プロパティ値

Boolean

Enter キーを押して、複数行形式のコントロールでテキストの改行を行う場合は true。Enter キーを押して、フォームの既定のボタンをアクティブにする場合は false。 既定値は、false です。

次のコード例では、垂直スクロール バーを含む複数行 TextBox コントロールを作成します。 次の使用例は、AcceptsReturn複数行のAcceptsTabテキスト ボックス コントロールをテキスト ドキュメントの作成に役立つプロパティとWordWrapプロパティを使用します。

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

注釈

このプロパティの値が指定されている場合、ユーザーは falseCtrl キーを押しながら Enter キーを押して、複数行 TextBox のコントロールに新しい行を作成する必要があります。 フォームに既定のボタンがない場合、Enter キーを押すと、このプロパティの値に関係なく、コントロールに新しいテキスト行が常に作成されます。

適用対象