Link to home
Start Free TrialLog in
Avatar of DebeG
DebeGFlag for United States of America

asked on

Form_Activate

I am sure this is a simple question.  Can anyone tell me why the form_activate doesn't always work?  I have a form that performs a form1.show.  In form1, when closing, I perform an unload me.  If I attempt to go back into form1, the form_activate doesn't work.  Actually sometimes it doesn't work on the first trip into form1.  

Any advice would be appreciated.  
Avatar of Marine
Marine

place a break point there and see what happends. Or step though your code by pressing F8
Avatar of Brendt Hess
It may depend on your code, and what you are checking.  An Unload doesn't remove everything from memory (for that you need to set the Form to Nothing), so if you are checking a flag to determine if the Activate code has already run, you may not be getting the value in the flag that you would expect.
Can you paste your code here?  It should work (and does for me), but maybe you're doing something different.
Form_Activate does only happen, if another (nonmodal) form in your application get's the focus.
The event is NOT fired when switching from your application to other and back.
The event is fired for MDIMain form when last MDIChild is closed.

if you need to check if form gets focus, you need API solution...

Hope this helps
Avatar of DebeG

ASKER

I don't have a good example of it.  I use the form_activate to load data into the form.  I have put breakpoints here and can see when performing a form1.show from formA, the form_activate in form1 doesn't trigger.  It does sometimes or most of the time work.  Like right now, I am debugging the code to determine what causes it to happen and form_activate occurs every time.  Yesterday it wasn't.  I just thought there was something about form_activate I didn't know about.  What causes it to trigger?

I thought it triggered everytime the form received focus.  Is that not correct?  
Maybe you should rather use Form_Load event to load your data initially.
Personnally, i only use the Activate Event when working with MDIChild forms
Good luck
Avatar of DebeG

ASKER

This question has a deletion request Pending
This question no longer is pending deletion
Why?  Sounds like it was answered by angelIII.
ASKER CERTIFIED SOLUTION
Avatar of Toad224
Toad224
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You are repeating my comment, Toad224
Sorry, I didn't read the comments