Saturday, August 8, 2009

Confirmation box in winform with yes/ no

Recently I need to write confirmation box in winform and based on the selection of my user (whether user select "Yes" or "no") , some action will be performed.

Lets have a look at the code snippet

DialogResult dResTest;
dResTest = MessageBox.Show( "Do you want to add something ?", "Confirm Document Close", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dResTest == DialogResult.No)
{
Application.Exit();
}
else
{

//Calling some function if user clicks Yes
ViewExistingTicket
();

}

Just use the intelliscense feature, you'll find some other useful properties after giving dot to MessageBoxButtons and MessageBoxIcon

No comments:

FEEDJIT Live Traffic Feed