You need to access the instance of your NumericUpDown
control being passed to the event through the sender
parameter. Try this: (untested)
(Also, remove System.Windows.Forms
from the beginning of the event name.)
private void NumericUpDown_Enter(object sender, EventArgs e)
{
var numUpDownControl = sender as System.Windows.Forms.NumericUpDown;
if (numUpDownControl != null)
numUpDownControl.Select(0, 2);
}
If you want to select the entire value in the control (and not just the first two numbers), change the Select
statement accordingly:
numUpDownControl.Select(0, numUpDownControl.Value.ToString().Length);