Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MessageBox - which button was pressed? 2

Status
Not open for further replies.

emblewembl

Programmer
May 16, 2002
171
GB
I am using a windows forms messageBox for the first time and i don't know how to tell whch button was pressed! My messageBox is as follows:

Code:
MessageBox.Show(this,"Selections","Confirm Image Selections",MessageBoxButtons.YesNo);

I want to respond differently when yes or no is clicked. Can anyone point me in the right direction?

i love chocolate
 
The overload of this method that you're using is defined as:
Code:
public static DialogResult Show(string, string, MessageBoxButtons);
So, to answer your question, it returns a DialogResult, which is an enum with these values:
Code:
Abort
Cancel
Ignore
No
None
OK
Retry
Yes
Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
DialogResult result = MessageBox.Show(this,"Selections","Confirm Image Selections",MessageBoxButtons.YesNo);
if (result == System.Windows.Forms.DialogResult.Yes)
{}
else if (result == System.Windows.Forms.DialogResult.No)
{}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top