TextBoxBase.Multiline プロパティ

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

Public Overridable Property Multiline As Boolean
[C#]
public virtual bool Multiline {get; set;}
[C++]
public: __property virtual bool get_Multiline();public: __property virtual void set_Multiline(bool);
[JScript]
public function get Multiline() : Boolean;public function set Multiline(Boolean);

プロパティ値

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

解説

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

改行文字として使用できる定数を次に示します。

  • System.Environment.Newline.
  • ControlChars.CrLf
  • vbCrLf (Visual Basic のみ)

ScrollBars プロパティを使用すると、テキスト ボックスにスクロール バーを追加したり、水平スクロール バーまたは垂直スクロール バー (あるいはその両方) を表示したりできます。ユーザーはスクロール バーを使用してコントロールに収まらないテキストをスクロールできます。

メモ   このプロパティは、 RichTextBox コントロール以外のすべての派生クラスの既定では、 false に設定されています。

使用例

[Visual Basic, C#, C++] 派生クラス TextBox を使用して、垂直スクロール バーのある複数行 TextBox コントロールを作成する例を次に示します。この例では、 AcceptsTabAcceptsReturnWordWrap の各プロパティも使用して、テキスト ドキュメントを作成しやすいように複数行テキスト ボックス コントロールを設定します。

 
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!"
End Sub


[C#] 
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!";
 }
 

[C++] 
public:
    void CreateMyMultilineTextBox() {
        // Create an instance of a TextBox control.
        TextBox __gc *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 = S"Welcome!";
    };

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

TextBoxBase クラス | TextBoxBase メンバ | System.Windows.Forms 名前空間 | Lines | WordWrap | ScrollBars