Search code examples
c#numericupdown

How to select Numeric UpDown value programmatically in Winforms?


I want to select the available value within the numeric up/down control using c#

enter image description here

and in general if we double click within the control then we get the following(the entire text gets selected colored Blue in BG)

enter image description here

Now my question is How do I achieve this pro-grammatically??


My trails so far :

Focus();

Select();

this doesn't seem to work, any help on this regard would be much appreciated, Thanks..:)


Solution

  • Select has an overload that takes two int, one for selection start, one for selection length:

    myNumericUpDown.Select(0, myNumericUpDown.Text.Length);