Bagikan melalui


TextBoxBase.BorderStyle Properti

Definisi

Mendapatkan atau mengatur tipe batas kontrol kotak teks.

public:
 property System::Windows::Forms::BorderStyle BorderStyle { System::Windows::Forms::BorderStyle get(); void set(System::Windows::Forms::BorderStyle value); };
public System.Windows.Forms.BorderStyle BorderStyle { get; set; }
member this.BorderStyle : System.Windows.Forms.BorderStyle with get, set
Public Property BorderStyle As BorderStyle

Nilai Properti

BorderStyle yang mewakili tipe batas kontrol kotak teks. Defaultnya adalah Fixed3D.

Pengecualian

Nilai yang tidak berada dalam rentang nilai yang valid untuk enumerasi ditetapkan ke properti .

Contoh

Contoh kode berikut menggunakan TextBox, kelas turunan, untuk membuat kotak teks yang dapat menampilkan teks dengan benar menggunakan Arial 20 titik dengan satu batas. Contoh ini menggunakan PreferredHeight properti untuk menentukan tinggi kontrol yang sesuai setelah font dan BorderStyle telah ditetapkan ke kontrol.

public:
   void CreateTextBox()
   {
      // Create an instance of the TextBox control.
      TextBox^ textBox1 = gcnew TextBox;
      
      // Set the TextBox Font property to Arial 20.
      textBox1->Font = gcnew System::Drawing::Font( "Arial", 20 );
      // Set the BorderStyle property to FixedSingle.
      textBox1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
      // Make the height of the control equal to the preferred height.
      textBox1->Height = textBox1->PreferredHeight;
   }
public void CreateTextBox()
 {
    // Create an instance of the TextBox control.
    TextBox textBox1 = new TextBox();
 
    // Set the TextBox Font property to Arial 20.
    textBox1.Font = new Font ("Arial" , 20);
    // Set the BorderStyle property to FixedSingle.
    textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    // Make the height of the control equal to the preferred height.
    textBox1.Height = textBox1.PreferredHeight;
 }
Public Sub CreateTextBox()
    ' Create an instance of the TextBox control.
    Dim textBox1 As New TextBox()
    
    ' Set the TextBox Font property to Arial 20.
    textBox1.Font = New Font("Arial", 20)
    ' Set the BorderStyle property to FixedSingle.
    textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
    ' Make the height of the control equal to the preferred height.
    textBox1.Height = textBox1.PreferredHeight
End Sub

Keterangan

Anda dapat menggunakan BorderStyle properti untuk membuat kontrol gaya tanpa batas dan datar, selain kontrol tiga dimensi default.

Nota

Kelas turunan, RichTextBox, tidak mendukung BorderStyle.FixedSingle gaya. Gaya ini akan menyebabkan BorderStyle penggunaan gaya sebagai gantinya BorderStyle.Fixed3D .

Berlaku untuk