Language

TextBoxBase.WordWrap プロパティ

定義

必要に応じて、複数行のテキスト ボックス コントロールが自動的に次の行の先頭に単語を折り返すかどうかを示します。

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

プロパティ値

true 複数行テキスト ボックス コントロールが単語を折り返す場合。ユーザーがコントロールの右端を超えて入力したときに、テキスト ボックス コントロールが自動的に水平方向にスクロールする場合に false します。 既定値は true です。

例

次のコード例では、派生クラス 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

注釈

このプロパティを true に設定すると、 ScrollBars プロパティの設定に関係なく、水平スクロール バーは表示されません。

Note

派生クラス TextBox、 TextAlign プロパティが HorizontalAlignment.Left に設定されていない限り、コントロール内のテキストは常に、このプロパティのプロパティ設定に関係なく折り返されます。

適用対象