数値入力させたい場合に何かとらくちんなコントロールですね。
Accelerations っていうプロパティがあるんですが、
MSDN をみてもなんのこっちゃ?と思ってましたが、
百聞は一見にしかず。
やってみるとすぐわかります。
ワタシのプログラムですと、NumericUpDown1 の矢印を 押しっぱなしにしておくと、ある一定の値を過ぎてから(たぶん 3 秒経過した時点の値)
100 ずつグワーッと値が上がり(下がり)始めます。
用途があんまり思いつかないんですけどね。まぁいっか。
■参考文献
NumericUpDown クラス
NumericUpDown コントロール (Windows フォーム)
NumericUpDownAcceleration クラス
■実行画像
なんもおもしろくない実行画面
Public Class NumericUpDownTest
Private Sub NumericUpDownTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With Me.NumericUpDown1
.DecimalPlaces = 2 ' 小数部の桁数
.Increment = 1.5D ' 矢印ボタンの 1 回クリックでどれだけ増加/減少するか
.InterceptArrowKeys = True ' 矢印キーによる値の増減を許可
.ReadOnly = True ' 矢印キーのみでの値の増減を行う
.ThousandsSeparator = True ' 桁区切り記号を表示する
.Maximum = 50000.8D ' 上限
.Minimum = -50000.8D ' 下限
.Value = 1500.25D ' 値の設定
' 矢印が指定秒数押された時に、どのような加速を適用するかを指定する
.Accelerations.Add(New NumericUpDownAcceleration(3, 100))
AddHandler .ValueChanged, AddressOf NumericUpDown_ValueChanged
.UpButton() ' 1 個上へ
End With
With Me.NumericUpDown2
.Hexadecimal = True ' 16 進表示
.UpDownAlign = LeftRightAlignment.Left ' 左側に矢印を表示
AddHandler .ValueChanged, AddressOf NumericUpDown_ValueChanged
.DownButton() ' 1 個下へ
End With
' マウスホイールで増減しない NumericUpDown
Dim nowheelUpDown As NoWheelNumericUpDown = New NoWheelNumericUpDown()
With nowheelUpDown
.Name = "NoWheelNumericUpDown1"
.Location = New Point(12, 62)
.BackColor = Color.LightBlue
AddHandler .ValueChanged, AddressOf NumericUpDown_ValueChanged
End With
Me.Controls.Add(nowheelUpDown)
End Sub
Private Sub NumericUpDown_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim numericUpDn As NumericUpDown = DirectCast(sender, NumericUpDown)
System.Diagnostics.Debug.WriteLine(numericUpDn.Name & ":" & numericUpDn.Value.ToString())
End Sub
End Class
Public Class NoWheelNumericUpDown
Inherits NumericUpDown
Protected Overrides Sub OnMouseWheel(ByVal e As System.Windows.Forms.MouseEventArgs)
'MyBase.OnMouseWheel(e)
End Sub
End Class