Form.ShowDialog(), how to disable exiting on button click

A

alberto

(using Windows CE, C#)
I have a form that is called with frmname.ShowDialog(), and it of
course has an OK button which returns a DialogResult.OK.
How can I disable closing the form when I want to (specifically, when
I get an exception from a database operation). In that case, instead
of exiting the form I want to display a MessageBox, and continue form.

Thanks in advance

Alberto
 
M

Martin CLAVREUIL

Hi alberto,

I guess you'd like something liker that ?

private void MyModalForm_Closing(object sender, CancelEventArgs e)
{
try
{
throw new Exception("oh rage, oh désespoir, oh
vieillesse ennemie ...");
}
catch (Exception ex)
{
MessageBox.Show("An error occured : " + ex.Message);
e.Cancel = true;
}
}
}

alberto wrote :
 

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