From: rarahim on
Hi.

I have a hidden form in my app. When i call that form's Close() method from
another form to close it, the form's FormClosing() and FormClosed() events
are not raised. Is this behaviour normal and expected?

Tq.


From: Patrice on
Hello,

> I have a hidden form in my app. When i call that form's Close() method
> from another form to close it, the form's FormClosing() and FormClosed()
> events are not raised. Is this behaviour normal and expected?

I don't see this behavior. They are raised (which is what I would expect).
How do you hide the form ? How do you know they are not raised ?

If I just instanciate the form I have the same behavior (the form is not
closed as it was never opened). Could it be what your code does ?

--
Patrice






From: PvdG42 on

"rarahim" <rarahim75(a)gmail.com> wrote in message
news:4bb1db83$1_1(a)news.tm.net.my...
> Hi.
>
> I have a hidden form in my app. When i call that form's Close() method
> from another form to close it, the form's FormClosing() and FormClosed()
> events are not raised. Is this behaviour normal and expected?
>
> Tq.
>

As Patrice said, please provide more detail. Simple tests here (VS 2008 and
VS 2010 RC) show both events firing in simple VB Winform test apps. Exactly
what type of project are you working with and what VS version? Any other
unique circumstances?

From: rarahim on
Hi.

Actually i did instantiate the form before hiding it.

Basically i have 2 forms, Form1 and Form2. In Form2 class, i declare an
object of type Form1 like so:

public Form1 frmParent;

Then in a button click event of Form1 i have:

private void button4_Click(object sender, EventArgs e)
{
Form2 form2obj = new Form2();
form2obj.frmParent = this;
this.Hide();

form2obj.MdiParent = MdiParent;
form2obj.Show();
}

Then in Form1's FormClosing event i have:

if (frmParent != null)
frmParent.Close();

I place some clean up code in Form2's FormClosing (and FormClosed) event but
the event never gets called.

What is wrong with this scenario?


"rarahim" <rarahim75(a)gmail.com> wrote in message
news:4bb1db83$1_1(a)news.tm.net.my...
> Hi.
>
> I have a hidden form in my app. When i call that form's Close() method
> from another form to close it, the form's FormClosing() and FormClosed()
> events are not raised. Is this behaviour normal and expected?
>
> Tq.
>



--- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: rarahim on
>
> I don't see this behavior. They are raised (which is what I would expect).
> How do you hide the form ? How do you know they are not raised ?
>

I placed a breakpoint on a statement in the FormClosing FormClosed events.



--- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---