Export (0) Print
Expand All

TextBoxBase.BorderStyle Property

Gets or sets the border type of the text box control.

[Visual Basic]
Public Property BorderStyle As BorderStyle
[C#]
public BorderStyle BorderStyle {get; set;}
[C++]
public: __property BorderStyle get_BorderStyle();
public: __property void set_BorderStyle(BorderStyle);
[JScript]
public function get BorderStyle() : BorderStyle;
public function set BorderStyle(BorderStyle);

Property Value

A BorderStyle that represents the border type of the text box control. The default is Fixed3D.

Exceptions

Exception Type Condition
InvalidEnumArgumentException A value that is not within the range of valid values for the enumeration was assigned to the property.

Remarks

You can use the BorderStyle property to create borderless and flat style controls, in addition to the default three-dimensional control.

Note   The derived class, RichTextBox, does not support the BorderStyle.FixedSingle style. This style will cause the borderstyle to use the BorderStyle.Fixed3D style instead.

Example

[Visual Basic, C#, C++] The following example uses TextBox, a derived class, to create a text box that can properly display text using 20-point Arial with a single border. 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.

[Visual Basic] 
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


[C#] 
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;
 }


[C++] 
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 System::Drawing::Font (S"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;
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

TextBoxBase Class | TextBoxBase Members | System.Windows.Forms Namespace

Show:
© 2014 Microsoft