I have some problems displaying a disabled form in a non-modal state. Here is a sample code:
public partial class Form1 : Form
{
private void button1_Click(object sender, EventArgs e)
{
try
{
Form2 form = new Form2();
form.Enabled = false;
form.Show();
form.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
Any idea why Show()(without a parameter) works but Show(this)gives an exception? In my script, I formshould know that its owner is shown correctly, so I can do the following:
form.Enabled = false;
form.Owner=this;
form.Show();
but is this really a good solution?
EDIT: Thanks for the quick answers. It seems that we really found a bug in the framework here. Despite your suggestions, I think I will continue my decision, since disabling the form after "Show" gives an ugly visible effect to the user.
source
share