Gets or sets the border style for the up-down 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);
One of the BorderStyle values. The default value is Fixed3D.
Exception Type | Condition |
---|---|
InvalidEnumArgumentException | The value assigned is not one of the BorderStyle values. |
You can use the BorderStyle property to create borderless and flat controls in addition to the default three-dimensional control.
The following example uses the derived class, NumericUpDown and sets some of its properties derived from UpDownBase. This code assumes you have a NumericUpDown control, two ComboBox controls, and three CheckBox controls instantiated on a form. Label the ComboBox controls: BorderStyle and TextAlign. Label the CheckBox controls: InterceptArrowKeys, ReadOnly, and UpDownAlign- Left. The code will allow you to change the property values at run time and see how each affect the appearance and behavior of the up-down control. See the table below for the appropriate values to be added to the ComboBox controls.
BorderStyle | TextAlign |
---|---|
None | Left |
Fixed3D | Right |
FixedSingle | Center |
[Visual Basic]
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) ' Set the TextAlign property. Select Case ComboBox2.Text Case "Right" NumericUpDown1.TextAlign = System.WinForms.HorizontalAlignment.Right Case "Left" NumericUpDown1.TextAlign = System.WinForms.HorizontalAlignment.Left Case "Center" NumericUpDown1.TextAlign = System.WinForms.HorizontalAlignment.Center End Select End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) ' Set the BorderStyle property. Select Case ComboBox1.Text Case "Fixed3D" NumericUpDown1.BorderStyle = System.WinForms.BorderStyle.Fixed3D Case "None" NumericUpDown1.BorderStyle = System.WinForms.BorderStyle.None Case "FixedSingle" NumericUpDown1.BorderStyle = System.WinForms.BorderStyle.FixedSingle End Select End Sub Private Sub CheckBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) ' Evaluate and toggle the UpDownAlign property. If NumericUpDown1.UpDownAlign = System.WinForms.LeftRightAlignment.Left Then NumericUpDown1.UpDownAlign = System.WinForms.LeftRightAlignment.Right Else NumericUpDown1.UpDownAlign = System.WinForms.LeftRightAlignment.Left End If End Sub Private Sub CheckBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) ' Evaluate and toggle the InterceptArrowKeys property. If NumericUpDown1.InterceptArrowKeys = True Then NumericUpDown1.InterceptArrowKeys = False Else NumericUpDown1.InterceptArrowKeys = True End If End Sub Private Sub CheckBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) ' Evaluate and toggle the ReadOnly property. If NumericUpDown1.ReadOnly = True Then NumericUpDown1.ReadOnly = False Else NumericUpDown1.ReadOnly = True End If End Sub
UpDownBase Class | UpDownBase Members | System.WinForms Namespace | BorderStyle