TextBoxBase.BorderStyle 屬性

定義

取得或設定文字方塊控制項的框線樣式。Gets or sets the border type of the text box control.

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,表示文字方塊控制項的框線樣式。A BorderStyle that represents the border type of the text box control. 預設為 Fixed3DThe default is Fixed3D.

例外狀況

不在列舉型別 (Enumeration) 有效值範圍內的值會指派給這個屬性。A value that is not within the range of valid values for the enumeration was assigned to the property.

範例

下列程式碼範例 TextBox 會使用衍生類別,以建立可使用具有單一框線的20點 Arial 來正確顯示文字的文字方塊。The following code example uses TextBox, a derived class, to create a text box that can properly display text using 20-point Arial with a single border. 這個範例會使用 PreferredHeight 屬性來判斷控制項在字型之後的適當高度,並且已 BorderStyle 指派給控制項。This example uses the PreferredHeight property to determine the appropriate height of the control after the font and BorderStyle have been assigned to the control.

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 屬性來建立無邊框和平面樣式控制項,以及預設的三維控制項。You can use the BorderStyle property to create borderless and flat style controls, in addition to the default three-dimensional control.

注意

衍生的類別不 RichTextBox 支援 BorderStyle.FixedSingle 樣式。The derived class, RichTextBox, does not support the BorderStyle.FixedSingle style. 此樣式會導致改用 BorderStyle BorderStyle.Fixed3D 樣式。This style will cause the BorderStyle to use the BorderStyle.Fixed3D style instead.

適用於