Поделиться через


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 представляющий тип границы элемента управления текстового поля. Значение по умолчанию — 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 стиля.

Применяется к