form.showDialog() does not work properly

  • Thread starter Thread starter PiotrKolodziej
  • Start date Start date
P

PiotrKolodziej

Hi

Iam running form2 from form1.
But as it was in many my previous applications, now the form2 doesn't
overlapp form1. It means that i can select form1 without even closing form2.

Here's sample code:

if (MessageBox.Show("Button is not recognized. Would you
like to add function to this button?", "New Button detected",
MessageBoxButtons.YesNo,
MessageBoxIcon.Information) == DialogResult.Yes)
{
Form2 form2 = new Form2();
form2.Button = "b" + t;
form2.ShowDialog();

Fill_DataGrid();
}
 
PiotrKolodziej said:
But as it was in many my previous applications, now the form2 doesn't
overlapp form1. It means that i can select form1 without even closing form2.

That's because the form isn't parented.
form2.ShowDialog();

You want the other ShowDialog, the one that takes a parent:

form2.ShowDialog(form1);

-- Barry
 

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