hey guys,

okay. this is another problem happening in an MDI form tab.

here's the sequence:
1. create tabcontrol.
2. create tabpage.
3. add a form(form1) into tabpage.
4. add tabpage to tabcontrol.

in form1, i have a textbox (textbox1) that does a validation whenever the Leave event is fired. what is does is refocus the focus onto textbox1 and highlight textbox1's text if there's an incorrect input.

everything seems fine before i moved it into the tabpage though. now whenever i click on something outside the form, such as the tabpage header, or a menu item, or whatever that makes the Leave event fire, the Leave event keeps firing non-stop creating an endless loop.

it seems that the textbox and the other control are trying to get the focus which is moving back and forth between them.

anyway idea how to prevent this from happening? or at least get it to fire only once then stop?


Have you dropped a debugger on that event to try and look at the call stack to determine exactly how that's being fired? It sounds like the tabpage or the textbox is actually losing focus every time, then when you highlight it, you get focus back.