TextBoxBase.WordWrap Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menunjukkan apakah kontrol kotak teks multibaris secara otomatis membungkus kata ke awal baris berikutnya jika diperlukan.
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
Nilai Properti
true jika kontrol kotak teks multibaris membungkus kata; false jika kontrol kotak teks secara otomatis menggulir secara horizontal saat jenis pengguna melewati tepi kanan kontrol. Defaultnya adalah true.
Contoh
Contoh kode berikut menggunakan TextBox, kelas turunan, untuk membuat kontrol multibaris TextBox dengan bilah gulir vertikal. Contoh ini juga menggunakan AcceptsTabproperti , AcceptsReturn, dan WordWrap untuk membuat kontrol kotak teks multibaris berguna untuk membuat dokumen teks.
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
Keterangan
Jika properti ini diatur ke true, bilah gulir horizontal tidak ditampilkan terlepas dari ScrollBars pengaturan properti.
Nota
Di kelas turunan, TextBox, teks dalam kontrol akan selalu membungkus terlepas dari pengaturan properti properti ini kecuali TextAlign properti diatur ke HorizontalAlignment.Left.