views:

235

answers:

3

I have a focus problem in C# GUI with tabs. I start a process based on an event with the users focus on a tab, and then run the process. The process repaints the the entire GUI -- and I'd like to put the user back on the initial tab.

Is there a way I can save the tab focus position when the event is triggered?

Cheers

A: 

Just save the SelectedTab (or SelectedIndex) property of your TabControl and then set it again afterwards.

Ed Swangren
int TabLocation = tabControl1.SelectedIndex;---run some stufftabControl1.SelectedIndex = TabLocation;Unfortunately, this looks "jerky" in the repaint. Is there anyway to set the tab selected when the items are initially made?
lw2009
Attach some code to the LostFocus event. http://msdn.microsoft.com/en-us/library/system.windows.forms.control.lostfocus.aspx
Mike Atlas
thx. 15 characters
lw2009
A: 

Store the tab focus position value when they first arrive on that tab. If the event fires afterward, you'll have already saved the prior position and can use that value to restore the original focus.

Mike Atlas