views:

70

answers:

1

Hi Guys,

I wonder if there is anyone who can help me?

The issue I have is a windows form TabPage stealing focus upon form re-activation. The form has a TabControl with four or five TabPages. Each tab page has many various controls.

The scenario is as follows: A user tabs through a few controls on the first TabPage and a new form is spawned and shown (say from one of the TextBox's Leave events) which removes focus from the first form as it takes focus itself. The users selects a value on the new form and closes it. - I would then expect the orginal form to know where the user had tabbed to and set focus to that control.

However, it seems when the form re-activates, it sets the focus, not back to where the user got to, or even the first control in the tab-order of the active TabPage. Instead it gives focus to the active TabPage itself.

Is there anywhere around this?

Thanks and kind regards, Duane.

+1  A: 

I have created variables (in the tab-control class, to keep them in scope) to store the current page and last page visited, also create a variable to store the control that had focus, use a pointer, reference, whatever.

When you go back, use the variable to restore focus to that control.

HTH

JustBoo
+1 Not a bad idea, I might have done the same.
Tony Abrams
Thanks, I'll have a look at implementing that technique when I am back in work on Monday. :o)
Dib