Modal form dialog

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
 
A

Arne Janning

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
 
S

Sreekanth

Can you send your code snippet please? Because I dont have any problem in
using ShowDialog.
Sree
 
K

kids_pro

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();
}
 
K

kids_pro

// 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();

}

}
 

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

Top