Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
TextBoxBase Class
 BorderStyle Property
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
TextBoxBase..::.BorderStyle Property

Updated: November 2007

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

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

Visual Basic (Declaration)
Public Property BorderStyle As BorderStyle
Visual Basic (Usage)
Dim instance As TextBoxBase
Dim value As BorderStyle

value = instance.BorderStyle

instance.BorderStyle = value
C#
public BorderStyle BorderStyle { get; set; }
Visual C++
public:
property BorderStyle BorderStyle {
    BorderStyle get ();
    void set (BorderStyle value);
}
J#
/** @property */
public BorderStyle get_BorderStyle()
/** @property */
public  void set_BorderStyle(BorderStyle value)
JScript
public function get BorderStyle () : BorderStyle
public function set BorderStyle (value : BorderStyle)

Property Value

Type: System.Windows.Forms..::.BorderStyle

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

ExceptionCondition
InvalidEnumArgumentException

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

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.

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. 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;
 }


Visual C++
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;
   }

J#
public void CreateTextBox()
{
    // Create an instance of the TextBox control.
    TextBox textBox1 = new TextBox();
    // Set the TextBox Font property to Arial 20.
    textBox1.set_Font(new Font("Arial", 20));
    // Set the BorderStyle property to FixedSingle.
    textBox1.set_BorderStyle(System.Windows.Forms.BorderStyle.FixedSingle);
    // Make the height of the control equal to the preferred height.
    textBox1.set_Height(textBox1.get_PreferredHeight());
} //CreateTextBox

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker