• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 931
  • Last Modified:

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.  
0
DebeG
Asked:
DebeG
  • 3
  • 3
  • 2
  • +3
1 Solution
 
MarineCommented:
place a break point there and see what happends. Or step though your code by pressing F8
0
 
Brendt HessSenior DBACommented:
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.
0
 
GivenRandyCommented:
Can you paste your code here?  It should work (and does for me), but maybe you're doing something different.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
0
 
DebeGProgrammerAuthor Commented:
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?  
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
0
 
DebeGProgrammerAuthor Commented:
This question has a deletion request Pending
0
 
GivenRandyCommented:
This question no longer is pending deletion
0
 
GivenRandyCommented:
Why?  Sounds like it was answered by angelIII.
0
 
Toad224Commented:
ok...  Form_Activate is usually used when using a MDI.  However... It is also called when a another form in your project is activated, and then you activate your form.  It is not called when another program is activated, and then your form is activated.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
You are repeating my comment, Toad224
0
 
Toad224Commented:
Sorry, I didn't read the comments
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 3
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now