I am having a hard time trying to select thet contents of a NumericUpDown
control when it gets focus. When the control gets focus I want all the
contents to be selected so that the user would per default overwrite it when
she enters data.

Basically I overrode OnEnter and did this.Select(0,
this.Value.ToString().Length); (seems a bit cumbersome, but I haven't found a
better way of doing it). Nothing happens.
MSDN documentation states NumericUpDown should have a Text property, I can't
see that it does. It does not have a Selection property either, so if I
needed the actual selected numbers I don't see how I would get that.

When you TAB into the control the contents is selected (as I want it) so I
know this must be possible to do when I select it with the mouse also.

Thanks.

RE: NumericUpDown select contents by Qpeg

Qpeg
Wed Aug 16 03:04:02 CDT 2006

Actually, while debugging I could see that the control has a Text property,
but it does not recognize this in Visual Studio (2005).. Anybody know why?

"Qpeg" wrote:

> I am having a hard time trying to select thet contents of a NumericUpDown
> control when it gets focus. When the control gets focus I want all the
> contents to be selected so that the user would per default overwrite it when
> she enters data.
>
> Basically I overrode OnEnter and did this.Select(0,
> this.Value.ToString().Length); (seems a bit cumbersome, but I haven't found a
> better way of doing it). Nothing happens.
> MSDN documentation states NumericUpDown should have a Text property, I can't
> see that it does. It does not have a Selection property either, so if I
> needed the actual selected numbers I don't see how I would get that.
>
> When you TAB into the control the contents is selected (as I want it) so I
> know this must be possible to do when I select it with the mouse also.
>
> Thanks.

RE: NumericUpDown select contents by Qpeg

Qpeg
Wed Aug 16 04:35:01 CDT 2006

Found 2 different solutions here:
http://blog.markarteaga.com/CommentView,guid,85271d7d-14a1-41dd-8469-d230a4e609cf.aspx
The one using the timer seems like the cleanest solution, although I don't
quite understand why it works. Anyone?