Modal form dialog

  • Thread starter Thread starter kids_pro
  • Start date Start date
K

kids_pro

Hi there,

I want to create a Modal dialog from.
Normally in vb it won't allow to click the parent form.

But I tried that in C# using form.ShowDialog(this);
I still can click on the mainForm event close the main form.

Does anyone know the trick of this?

Cheers,
Kids
 
kids_pro said:
Hi there,

I want to create a Modal dialog from.
Normally in vb it won't allow to click the parent form.

But I tried that in C# using form.ShowDialog(this);
I still can click on the mainForm event close the main form.

Does anyone know the trick of this?


Sorry,

cannot reproduce this. Are you sure?

private void button1_Click(object sender, System.EventArgs e)
{
Form2 f = new Form2();
f.ShowDialog(this);
}

Cheers

Arne Janning
 
Can you send your code snippet please? Because I dont have any problem in
using ShowDialog.
Sree
 
Oh I know what happen.
Because I put long running procedure in the Modal form.

in MainForm:
Form2 frm = new Form2();
frm.ShowDialog(this);

in Form2_Load(..,..){
this.Visible = true;
// long running part it take about 1 minute or more
// during this period I can click on the parent form and event close it.
// try it out you will see.
this.Close();
}
 
// Oop the actual part to cuz this behavior is Application.Doevents();

this.Visible = true;

for(int i =0; i<20000;i++){

for(int j=0;j<10000;j++){}

Application.DoEvents();

this.Text = i.ToString();

}

}
 
Back
Top