954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Endless loop while losing focus

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?

regards.

gp04lch
Light Poster
46 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

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.

alc6379
Cookie... That's it
Team Colleague
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You