// initializes the variables to pass to the messagebox.show method.
string message = "you did not enter a server name. cancel this operation?"; string caption = "no server name specified"; messageboxbuttons buttons = messageboxbuttons.yesno; dialogresult result;
// displays the messagebox.
result = messagebox.show(this, message, caption, buttons, messageboxicon.question, messageboxdefaultbutton.button1, messageboxoptions.rightalign);
if(result == dialogresult.yes) { //do your action here. }