共用方式為


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 A 代表文字框控制項的邊界類型。 預設值為 Fixed3D

例外狀況

一個不在列舉有效值範圍內的值被賦予該屬性。

範例

以下程式碼範例使用 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 風格。

適用於