TextBoxBase.BorderStyle Egenskap

Definition

Hämtar eller anger kantlinjetypen för textrutekontrollen.

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

Egenskapsvärde

En BorderStyle som representerar kantlinjetypen för textrutekontrollen. Standardvärdet är Fixed3D.

Undantag

Ett värde som inte ligger inom intervallet med giltiga värden för uppräkningen tilldelades egenskapen.

Exempel

I följande kodexempel används TextBox, en härledd klass, för att skapa en textruta som korrekt kan visa text med hjälp av 20-punkts Arial med en enda kantlinje. I det PreferredHeight här exemplet används egenskapen för att fastställa lämplig höjd för kontrollen efter teckensnittet och BorderStyle har tilldelats till kontrollen.

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

Kommentarer

Du kan använda BorderStyle egenskapen för att skapa kontroller med kantlinje och platt format, utöver den tredimensionella standardkontrollen.

Note

Den härledda klassen, RichTextBox, stöder inte formatmallen BorderStyle.FixedSingle . Det här formatet gör att formatmallen BorderStyleBorderStyle.Fixed3D används i stället.

Gäller för