Reading result from MessageBox

  • Thread starter Thread starter Kavvy
  • Start date Start date
K

Kavvy

Hi

How can I read the result from the following,

MessageBox.Show("Are you sure?", "Delete entry", MessageBoxButtons.YesNo,
MessageBoxIcon.Question);

Thanks!
Rich.
 
DialogResult result = MessageBox.Show("Are you sure?", "Delete entry",
MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
.....
 
Hi,
You could try doing it like this.

DialogResult dgRes = MessageBox.Show("This is an
error","Error",MessageBoxButtons.OKCancel,MessageBoxIcon.Error);
if(dgRes == DialogResult.ok)
{
//Your Code
}
else
if(dgRes == DialogResult.Cancel)
{
//Your Code
}

Tarakeshwar
 
Kavvy said:
How can I read the result from the following,

MessageBox.Show("Are you sure?", "Delete entry", MessageBoxButtons.YesNo,
MessageBoxIcon.Question);

Use the return value of MessageBox.Show.
 
yes. after clicking on Yes or No, the dialog will be gone. just try it
 
I know they will be gone, after a selection, I was asking about the behind
the scenes (are they just hidden). Since their dialogresult property is
still accessible, I'm assuming they are not yet disposed? When do they get
disposed then?
 
I guess you should not worry about disposing and leave it to garbage
collector to remove it from the memory. it's not like odbc connection which
you should dispose.
 
Althought it's good to know the behind the scenes, which is my purpose...
 

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

Back
Top