TextBoxBase.Multiline プロパティ

定義

このコントロールが複数行テキスト ボックス コントロールかどうかを示す値を取得または設定します。

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

プロパティ値

Boolean

コントロールが複数行テキスト ボックス コントロールである場合は true。それ以外の場合は false。 既定値は、false です。

次のコード例では、派生クラスを使用 TextBoxして、垂直スクロール バーを含む複数行 TextBox コントロールを作成します。 この例では、複数行の AcceptsTabテキスト ボックス コントロールをテキスト ドキュメントの作成に役立つものにするために、プロパティ AcceptsReturn、、および 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 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!" + Environment::NewLine + "Second Line";
   }
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 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!" + Environment.NewLine + "Second Line";
 }
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 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!" & Environment.NewLine & "Second Line"
End Sub

注釈

複数行のテキスト ボックスを使用すると、コントロールに複数行のテキストを表示できます。 プロパティが WordWrap 設定 trueされている場合、複数行のテキスト ボックスに入力されたテキストは、コントロール内の次の行にラップされます。 プロパティが WordWrap 設定 falseされている場合、複数行のテキスト ボックス コントロールに入力されたテキストは、改行文字が入力されるまで同じ行に表示されます。

改行文字として使用できるのは次のとおりです。

プロパティを使用して ScrollBars テキスト ボックスにスクロール バーを追加すると、水平スクロール バーや垂直スクロール バーを表示できます。 これにより、ユーザーはコントロールの次元を超えて拡張されるテキストをスクロールできます。

注意

プロパティの Multiline 既定値は false既定値であるため、サイズを変更しても、a TextBox の既定のサイズはフォント サイズに TextBox従います。 一貫性のあるサイズを TextBox取得するには、その Multiline プロパティ trueを .

注意

日本のオペレーティングシステムでは、プロパティが Multiline 設定 trueされている場合、プロパティを PasswordChar 設定するとパスワードのテキストが表示され、システムのセキュリティが損なわれます。 したがって、日本語のオペレーティング システムでは、プロパティを Multiline 設定する場合に false プロパティを設定します PasswordChar

注意

このプロパティは、コントロールを false 除き RichTextBox 、すべての派生クラスに対して既定で設定されます。

コントロールの RichTextBox 場合、このプロパティは RichTextBox.Multiline 、次のようにコントロールのサイズを自動的に変更するかどうかに影響します。

適用対象

こちらもご覧ください