close hide

  • Thread starter Thread starter Maarten
  • Start date Start date
M

Maarten

Hi

I'm trying to make something i tought is was simple

if i press the cross on the childform to close it, i want it to hide.
but when i press a button on the parrent i want to close the child.

so on the child i made a formclosing handler an in the handler i put:
this.hide();

now on the parrentform i do:
parrentform.Close();

but... ofcourse when i do this the closing eventhandler on the form is
called and the form hides itselfe.

what can i do?
 
Maarten,

Expose a flag on the child form which indicates whether or not the
parent form is closing it. Before the parent form closes the child form,
set the flag to true.

Then, in your form closing event handler, check the flag. If the flag
is true, then do not hide the form and cancel the event, rather, just let it
close.

Hope this helps.
 
how can i indicate wether the form itselve or the Parrent is closing it?


Nicholas Paldino said:
Maarten,

Expose a flag on the child form which indicates whether or not the
parent form is closing it. Before the parent form closes the child form,
set the flag to true.

Then, in your form closing event handler, check the flag. If the flag
is true, then do not hide the form and cancel the event, rather, just let it
close.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Maarten said:
Hi

I'm trying to make something i tought is was simple

if i press the cross on the childform to close it, i want it to hide.
but when i press a button on the parrent i want to close the child.

so on the child i made a formclosing handler an in the handler i put:
this.hide();

now on the parrentform i do:
parrentform.Close();

but... ofcourse when i do this the closing eventhandler on the form is
called and the form hides itselfe.

what can i do?
 
Maarten,

Expose a property that the parent form will call which will set a flag
on the child form. Either that, or expose another Close method which the
parent form will call which will set the flag in the child form internally.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Maarten said:
how can i indicate wether the form itselve or the Parrent is closing it?


in
message news:#[email protected]...
Maarten,

Expose a flag on the child form which indicates whether or not the
parent form is closing it. Before the parent form closes the child form,
set the flag to true.

Then, in your form closing event handler, check the flag. If the
flag
is true, then do not hide the form and cancel the event, rather, just let it
close.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Maarten said:
Hi

I'm trying to make something i tought is was simple

if i press the cross on the childform to close it, i want it to hide.
but when i press a button on the parrent i want to close the child.

so on the child i made a formclosing handler an in the handler i put:
this.hide();

now on the parrentform i do:
parrentform.Close();

but... ofcourse when i do this the closing eventhandler on the form is
called and the form hides itselfe.

what can i do?
 
indeed
thanks this was actualy not that hard.

regards maarten.


Nicholas Paldino said:
Maarten,

Expose a property that the parent form will call which will set a flag
on the child form. Either that, or expose another Close method which the
parent form will call which will set the flag in the child form internally.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Maarten said:
how can i indicate wether the form itselve or the Parrent is closing it?


in
message news:#[email protected]...
Maarten,

Expose a flag on the child form which indicates whether or not the
parent form is closing it. Before the parent form closes the child form,
set the flag to true.

Then, in your form closing event handler, check the flag. If the
flag
is true, then do not hide the form and cancel the event, rather, just
let
it
close.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi

I'm trying to make something i tought is was simple

if i press the cross on the childform to close it, i want it to hide.
but when i press a button on the parrent i want to close the child.

so on the child i made a formclosing handler an in the handler i put:
this.hide();

now on the parrentform i do:
parrentform.Close();

but... ofcourse when i do this the closing eventhandler on the form is
called and the form hides itselfe.

what can i do?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top