TextBoxBase.WordWrap Eigenschaft
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Gibt an, ob bei Bedarf automatisch ein mehrzeiliges Textfeld-Steuerelement Wörter an den Anfang der nächsten Zeile umschließt.
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
Eigenschaftswert
true wenn das mehrzeile Textfeld-Steuerelement Wörter umschließt; false wenn das Textfeld-Steuerelement automatisch horizontal scrollt, wenn der Benutzer den rechten Rand des Steuerelements übergibt. Der Standardwert lautet true.
Beispiele
Im folgenden Codebeispiel wird TextBox eine abgeleitete Klasse verwendet, um ein mehrzeiliges TextBox Steuerelement mit vertikalen Bildlaufleisten zu erstellen. In diesem Beispiel werden auch die Eigenschaften AcceptsTab, AcceptsReturn und WordWrap verwendet, um das Mehrzeilen-Textfeld-Steuerelement nützlich für die Erstellung von Textdokumenten zu machen.
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
Hinweise
Wenn diese Eigenschaft auf true festgelegt ist, werden horizontale Bildlaufleisten unabhängig von der Einstellung der ScrollBars Eigenschaft nicht angezeigt.
Hinweis
In der abgeleiteten Klasse wird Text innerhalb des Steuerelements unabhängig von der Eigenschaftseinstellung dieser Eigenschaft immer umbrochen, es sei denn, TextBoxdie TextAlign Eigenschaft ist auf HorizontalAlignment.Leftfestgelegt.