Events in other forms

stordaz

Newcomer
Joined
Apr 15, 2003
Messages
16
Location
Italy
Hi,
is it possible to call an event in another form?
I mean: from Form1 may I execute a Form2_Activated?

Thx
 
Well, you could mark the function as public so that another form could see the function. Remember that events are really just functions that are hooked up to get called automatically by windows. But you can still change the "private" word to "public".

If it were me, I'd put the code that's currently in your activate event into a separate function. I'd then have the activate event call this function. This function could be marked as public and this function is the one I'd call from the other form.

It strikes me as odd that the code you want to run when the form is activated needs to be run from another form...

Regardless of how you declare the function, you're going to also need a reference to the form. I'm not sure of how things are setup, but that might be an issue if you're trying to use the class name as the reference (as you could do in VB6). If that's the case, just ask and we can answer.

-nerseus
 
In fact it's odd... I was just trying to try to find a way to run the code written in the Activate Event of another form without calling a global subroutine, leaving the Activate code as it was. There was a bug I wasn't able to find it and that was just a way to discover it.

Now I've found it and solved it.

Thank you for replying to such an odd question!
 
Back
Top