I subclassed a textbox according to my needs by example from here
On same way I try to subclass NumericUpDown control to get selectAll functionality on them and to replace if point (".") char is pressed to comma (",") char to suit NumericUpDown control more suitable to my locale.
But I can't do that because NumericUpDown haven't a same properties like textbox has and I would like that both those controls behave at same way.
In my code two problems remains, SelectAll and SelectionLength :
Option Explicit On
Option Strict On
Public Class xNumericUpDown
Inherits NumericUpDown
Private alreadyFocused As Boolean
Protected Overrides Sub OnLeave(ByVal e As EventArgs)
MyBase.OnLeave(e)
Me.alreadyFocused = False
End Sub
Protected Overrides Sub OnGotFocus(ByVal e As EventArgs)
MyBase.OnGotFocus(e)
If MouseButtons = MouseButtons.None Then
Me.SelectAll() ' HOW TO MAKE SELECTALL SUB FOR NUMERICUPDOWN?
Me.alreadyFocused = True
End If
End Sub
Protected Overrides Sub OnMouseUp(ByVal mevent As MouseEventArgs)
MyBase.OnMouseUp(mevent)
If Not Me.alreadyFocused AndAlso Me.SelectionLength = 0 Then ' HOW TO CHECK SELECTIONLENGTH FOR NUMERICUPDOWN?
Me.alreadyFocused = True
Me.SelectAll() ' HOW TO MAKE SELECTALL SUB FOR NUMERICUPDOWN?
End If
End Sub
Protected Overrides Sub OnKeyPress(ByVal keyevent As KeyPressEventArgs)
MyBase.OnKeyPress(keyevent)
If keyevent.KeyChar = "." Then
keyevent.KeyChar = CChar(",")
End If
End Sub
End Class
Please help to get this working.