Fail to get the focus back from NumericUpDown control

  • Thread starter Thread starter Sharon
  • Start date Start date
I don't recall seeing this when originally posted.

Now that I look at it, I don't really understand how to help. You have
shown no code. The original post describes a strange desire, that I cannot
comprehend clearly. You have a numeric-up/down on a control B, and after
the user unclicks the up/down, you want some foreign control A to take
focus. This seems distracting to the user, if I follow the goal.

If I understand your goal, then it seems Control B could raise a custom
event that Control A would subscribe, when the numeric control was released.
Control A would focus within it when the event occurs.
 
I don't think I'm doing anything strange. I'll try to be more clear.

I' writing a UserControl derived class A.
A contains another UserControl derived class B.
B contains 2 Label controls and 2 NumericUpDown controls.

What supposed to happen:
The user click on one of the NumericUpDown arrows to set it's value.
Then the user click on the parent class A area (large area that draw
something).
A should get the focus.

What actually happens:
After the user click on A area, the focus remains at the NumericUpDown.


I tried handling the MouseUp event of A to take the focus by Focus() (or by
Select()) but the focus stays at the NumericUpDown.
I used the CanFocus at A MouseUp event handler and it returns true, still;
the following Focus() and Select() fails.

Note: After the application starts, the focus is set correctly at the parent
A control,
but I can get the focus back after the NumericUpDown has taken it.


How can I take the focus back to control A when the user wishes to by
clicking on the A area?
 
The Validate and Focus methods on the NumericUpDown control are
broken. You can see that that they are called out of order if you
browse in with Reflector. You will need to make your own NumericUpDown
that inherits from NumericUpDown base to work around the problem.
 
This was my suspicion as well.
I did build a derived class out of the NumericUpDown for other workaround.

Can you be more specific on the NumericUpDown and the workaround?

Is there on open bug at MS about it you can forward me to?
 
I did build a derived class out of the NumericUpDown for other workaround.

You should probably inherit from UpDownBase instead.
Can you be more specific on the NumericUpDown and the workaround?

The work-around was to build my own control on top of UpDownBase.
Is there on open bug at MS about it you can forward me to?

There is not an official bug. The bug is that "base.OnLostFocus" is
called out of order in the override of OnLostFocus (if I remember
correctly). I looked at the time on MS Feedback but didn't see
anything about it and didn't post anything about it because all my
other WinForms bugs were rejected with "dead since 2003" messages.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top