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.
Qpeg - 16 Aug 2006 09:04 GMT
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?
> 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
[quoted text clipped - 12 lines]
>
> Thanks.
Qpeg - 16 Aug 2006 10:35 GMT
Found 2 different solutions here:
http://blog.markarteaga.com/CommentView,guid,85271d7d-14a1-41dd-8469-d230a4e609c
f.aspx
The one using the timer seems like the cleanest solution, although I don't
quite understand why it works. Anyone?