Gets or sets a value indicating whether the user can use the UP ARROW and DOWN ARROW keys to select values.
[Visual Basic] Public Property InterceptArrowKeys As Boolean [C#] public bool InterceptArrowKeys {get; set;} [C++] public: __property bool get_InterceptArrowKeys(); public: __property void set_InterceptArrowKeys(bool); [JScript] public function get InterceptArrowKeys() : Boolean; public function set InterceptArrowKeys(Boolean);
true if the control allows the use of the UP ARROW and DOWN ARROW keys to select values; otherwise, false. The default value is true.
If InterceptArrowKeys is set to true and the up-down control has focus, the user may use the UP ARROW and DOWN ARROW keys to select values.
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