Bagikan melalui


TextBoxBase.Multiline Properti

Definisi

Mendapatkan atau mengatur nilai yang menunjukkan apakah ini adalah kontrol kotak teks multibaris.

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

Nilai Properti

true jika kontrol adalah kontrol kotak teks multibaris; jika tidak, false. Defaultnya adalah false.

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

Kotak teks multibaris memungkinkan Anda menampilkan lebih dari satu baris teks dalam kontrol. WordWrap Jika properti diatur ke true, teks yang dimasukkan ke dalam kotak teks multibaris dibungkus ke baris berikutnya dalam kontrol. WordWrap Jika properti diatur ke false, teks yang dimasukkan ke dalam kontrol kotak teks multibaris akan ditampilkan pada baris yang sama hingga karakter baris baru dimasukkan.

Berikut ini dapat digunakan sebagai karakter baris baru:

Anda dapat menambahkan bilah gulir ke kotak teks menggunakan ScrollBars properti untuk menampilkan bilah gulir horizontal dan/atau vertikal. Ini memungkinkan pengguna untuk menggulir teks yang meluas di luar dimensi kontrol.

Nota

Karena nilai Multiline default properti adalah false, ukuran default akan TextBox sesuai dengan ukuran font bahkan jika Anda mengubah ukuran TextBox. Untuk mendapatkan ukuran yang konsisten untuk Anda TextBox, atur propertinya Multiline ke true.

Nota

Pada sistem operasi Jepang, jika Multiline properti diatur ke true, mengatur PasswordChar properti akan menampilkan teks kata sandi, sehingga mengorbankan keamanan sistem. Oleh karena itu, pada sistem operasi Jepang, atur properti ke Multilinefalse jika Anda mengatur PasswordChar properti .

Nota

Properti ini diatur ke false secara default untuk semua kelas turunan RichTextBox , dengan pengecualian kontrol.

RichTextBox Untuk kontrol, RichTextBox.Multiline properti memengaruhi apakah kontrol akan mengubah ukuran secara otomatis atau tidak, sebagai berikut:

Berlaku untuk

Lihat juga