Create Modal Popup Dialog in C#
Rawa’a Al-Jabaly replied to Shallu Gupta on 19-Mar-09 06:36 AM
|Any form has the (AcceptButton and Cancel Button Properties) so create your form with two buttons, one is ok and the other is cancel. set AcceptButton = ok and CancelButton = cancel. After creating an instance from this form, use ShowDialog() method instead of Show(). The following example will explain to you what I mean:
Form1 frm = new Form1();
//Form1 has two buttons, button1 name is btnOk and button2 name is btnCancel
frm.AcceptButton = btnOk; //if you do this, then no need to write the OK handler.
frm.CancelButton = btnCancel; //if you do this, then no need to write the cancel handler.
frm.ShowDialog(); //creates a modal dialog.