---
title: "Result of clicking No button on a MessageBox dialog class."  
description: "Result of clicking No button on a MessageBox dialog class."  
author: "Anonymous User"  
published: 2011-08-24  
updated: 2011-08-24  
canonical: https://www.mindstick.com/forum/293/result-of-clicking-no-button-on-a-messagebox-dialog-class  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Result of clicking No button on a MessageBox dialog class.

Hi all,\
I have a following line of code\
MessageBox.Show("Are you sure you want to [download](https://www.mindstick.com/articles/188403/website-to-download-photos-from-instagram)? Click 'YES' to [Import](https://www.mindstick.com/blog/294/how-to-import-or-export-sql-server-table-data-in-ms-excel-sheet-using-c-sharp-code) (or) 'NO' to [cancel](https://answers.mindstick.com/qa/94501/how-can-i-cancel-my-singapore-flight-ticket)", "Confirmation [Message](https://www.mindstick.com/forum/12802/show-confirmation-message-yes-or-no-in-asp-dot-net)", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\
\
\
I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to set it so that if the user clickes no, then it goes back to the original form and sets a button to visible and a [label](https://www.mindstick.com/articles/12835/print-label-tracking-how-do-these-features-make-auspost-woocommerce-plugin-better) to invisible. I know the code to take care of the button and label, but I'm not sure how to take care of the [result](https://www.mindstick.com/blog/12011/advantages-of-getting-result-oriented-seo-from-an-agency) of the No [button click](https://www.mindstick.com/forum/790/form-gets-submiited-twice-on-button-click).\
\
Any help could be appreciated.\
Thanks.\

## Replies

### Reply by James Smith

Hi Awadhendra,\
\
You can use DialogResult property for solving your problem. Like in following algorithm I will explain it.\
\

```
if(MessageBox.Show("Click","Confirmation",MessageBox.OKCancel,MessageBoxIcon.Warning)==DialogResult.OK){        //Write code if OK button is clicked.}else{      //Write code if other button is clicked.}
```

\
Thanks.


---

Original Source: https://www.mindstick.com/forum/293/result-of-clicking-no-button-on-a-messagebox-dialog-class

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
