problems displaying forms correctly

  • Thread starter Thread starter =?ISO-8859-1?Q?S=E9rgio_Almeida?=
  • Start date Start date
?

=?ISO-8859-1?Q?S=E9rgio_Almeida?=

Greetings

I have a very simple question. I'm having some problems working with forms.

On my winforms application, I have a form (main_form) that display
another form that shows a listing od data. This sencond form
(listing_form) is displayed with the ShowDialog(this) method (called
from main_form). On this second form I have a "new item" button that
displays a third form (data_form) for data input. What I want is, when
the button "new item" is pressed, the form listing_form closes and the
form data_form appears. So I cannot use ShowDialog(main_form) from
listing_form to display the data_form because listing_form does not
closes (it waits for the data_form to close). What I need is the
data_form to be called/displayed from the listing_form and be modal
relative to the main_form, and close the listing_form at the time the
data_form is displayed. Any ideas how can I achive this?

Thanks in advance

Almeida
 
Hi Almeida,

If I understand you correctly you can just put this in your "New Item" button code

in main_form

if(listing_form.ShowDialog() == DialogResult.Yes)
{
// show data_form
}

in listing_form's new button code

this.DialogResult = DialogResult.Yes;
this.Close();

You can change the DialogResult to whatever you want, it works sort of like an exit code.


Happy coding!
Morten Wennevik [C# MVP]
 
Back
Top