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

プロパティ値

true Enter キーを押すと、コントロールの複数行バージョンに新しいテキスト行が作成されます。Enter キーを押すと、フォームの既定のボタンがアクティブ化される場合に false します。 既定値は false です。

次のコード例では、垂直スクロール バーを含む複数行 TextBox コントロールを作成します。 次の使用例は、 AcceptsTabAcceptsReturn、および 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

注釈

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

適用対象