Condividi tramite


TextBoxBase.BorderStyle Proprietà

Definizione

Ottiene o imposta il tipo di bordo del controllo casella di testo.

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

Valore della proprietà

Oggetto BorderStyle che rappresenta il tipo di bordo del controllo casella di testo. Il valore predefinito è Fixed3D.

Eccezioni

Un valore non compreso nell'intervallo di valori validi per l'enumerazione è stato assegnato alla proprietà .

Esempio

Nell'esempio di codice seguente viene TextBoxutilizzato , una classe derivata, per creare una casella di testo in grado di visualizzare correttamente il testo usando Arial a 20 punti con un singolo bordo. In questo esempio viene utilizzata la PreferredHeight proprietà per determinare l'altezza appropriata del controllo dopo il tipo di carattere e BorderStyle l'assegnazione al controllo.

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

Commenti

È possibile utilizzare la BorderStyle proprietà per creare controlli di stile senza bordi e flat, oltre al controllo tridimensionale predefinito.

Annotazioni

La classe derivata, RichTextBox, non supporta lo BorderStyle.FixedSingle stile . Questo stile causerà invece l'utilizzo BorderStyle dello stile da parte di BorderStyle.Fixed3D .

Si applica a