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.
 
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.
 
Back
Top