TextBoxBase.BorderStyle 属性

获取或设置文本框控件的边框类型。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Property BorderStyle As BorderStyle
用法
Dim instance As TextBoxBase
Dim value As BorderStyle

value = instance.BorderStyle

instance.BorderStyle = value
public BorderStyle BorderStyle { get; set; }
public:
property BorderStyle BorderStyle {
    BorderStyle get ();
    void set (BorderStyle value);
}
/** @property */
public BorderStyle get_BorderStyle ()

/** @property */
public void set_BorderStyle (BorderStyle value)
public function get BorderStyle () : BorderStyle

public function set BorderStyle (value : BorderStyle)

属性值

表示文本框控件边框类型的 BorderStyle。默认为 Fixed3D

异常

异常类型 条件

InvalidEnumArgumentException

分配给该属性的值不在该枚举的有效值范围内。

备注

除了默认的三维控件之外,您还可以使用 BorderStyle 属性创建无边框和平面样式的控件。

提示

派生类 RichTextBox 不支持 BorderStyle.FixedSingle 样式。此样式将使 BorderStyle 转为使用 BorderStyle.Fixed3D 样式。

示例

下面的代码示例使用派生类 TextBox 创建一个文本框,此文本框可使用 20 磅 Arial 字体及单线边框正确显示文本。在把字体和 BorderStyle 指派给该控件之后,此示例使用 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
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:
   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.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 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0

请参见

参考

TextBoxBase 类
TextBoxBase 成员
System.Windows.Forms 命名空间