[gui] closing or hiding a parent form

  • Thread starter Thread starter Thorsten Ottosen
  • Start date Start date
T

Thorsten Ottosen

Dear all,

Is it possible to close or hide a parent form?

In particular, is it possible to do from the child form itself?

Thanks

Thorsten
 
Hi,

Pass the parent form as part of the constructor of the child form, then as
needed call Hide()


cheers,
 
Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

Pass the parent form as part of the constructor of the child form, then
as needed call Hide()

For some reason this does not work as I expect.

-Thorsten
 
Ignacio Machin ( .NET/ C# MVP ) said:
hi

post the code you are using

Can't do that; sorry.

But I can describe the situation a little better (something I should have
done the first time :-()

We start with the parent form:

using(frmMedarbejderListe f = new frmMedarbejderListe(
m_erMedarbejdersErindringer ) )
{
f.Open( this );
}

Then in the child form I do

public override void Open( Form parent )
{
frmMedarbejderSoeg fader = parent as frmMedarbejderSoeg;
fader.Hide(); // #2
Debug.Assert( fader.Visible == false );

base.Open( parent ); // #2
}

base.Open(parent) does various stuff, but ends up calling this.ShowDialog();

Now, the funny this is that if reorder the lines marked #1 and #2, the
parent form is not
hidden...when I look behind the child window, the parent form is still
there;

If I don't reorder the two lines, the parent form is hidden, but the screen
flickers
a bit before the child window appears proproly on the screen.

Neither behavior is particular good.

br

Thorsten
 

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