TextBoxBase.BorderStyle 屬性

定義

取得或設定文字方塊控制項的框線樣式。

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

屬性值

BorderStyle

BorderStyle,表示文字方塊控制項的框線樣式。 預設為 Fixed3D

例外狀況

不在列舉型別 (Enumeration) 有效值範圍內的值會指派給這個屬性。

範例

下列程式碼範例會使用 TextBox 衍生類別來建立文字方塊,以使用 20 點 Arial 搭配單一框線正確顯示文字。 本範例會 PreferredHeight 使用 屬性,在字型之後判斷控制項的適當高度,並 BorderStyle 已指派給控制項。

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

備註

除了預設的三維控制項之外,您可以使用 BorderStyle 屬性來建立無框線和平面樣式控制項。

注意

衍生類別 RichTextBox 不支援 BorderStyle.FixedSingle 樣式。 此樣式會導致 BorderStyle 改用 BorderStyle.Fixed3D 樣式。

適用於