Nyelv

TextBoxBase.WordWrap Tulajdonság

Definíció

Azt jelzi, hogy egy többsoros szövegdoboz vezérlőelem szükség esetén automatikusan a következő sor elejére tördeli-e a szavakat.

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

Tulajdonság értéke

true ha a többsoros szövegdoboz vezérlőelem szavakat tördel; false ha a szövegdoboz vezérlőelem automatikusan vízszintesen görget, amikor a felhasználó a vezérlő jobb széle mellett típusok. Az alapértelmezett érték a true.

Példák

Az alábbi példakód TextBoxegy származtatott osztály használatával hoz létre egy többsoros TextBox vezérlőt függőleges görgetősávokkal. Ez a példa a AcceptsTab, AcceptsReturnés WordWrap a tulajdonságok használatával is hasznossá teszi a többsoros szövegdoboz-vezérlőt a szövegdokumentumok létrehozásához.

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

Megjegyzések

Ha ez a tulajdonság be van állítva true, a vízszintes görgetősávok a tulajdonságbeállítástól függetlenül ScrollBars nem jelennek meg.

Note

A származtatott osztályban TextBoxa vezérlőelemen belüli szöveg mindig körbefut a tulajdonság tulajdonságbeállításától függetlenül, kivéve, ha a TextAlign tulajdonság értéke HorizontalAlignment.Left.

A következőre érvényes: