---
title: "Catching MessageBox result"  
description: "Catching MessageBox result"  
author: "Anonymous User"  
published: 2013-10-04  
updated: 2013-10-04  
canonical: https://www.mindstick.com/forum/1582/catching-messagebox-result  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Catching MessageBox result

I'm [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to get the user to [confirm](https://answers.mindstick.com/qa/115761/facebook-account-locked-with-confirm-your-identity-loop) if they want to [delete](https://www.mindstick.com/forum/33620/how-to-delete-record-from-list-in-mvc-using-ajax) a [product](https://www.mindstick.com/articles/75385/full-product-keys) using a MessageBox and catching its [result](https://www.mindstick.com/blog/12011/advantages-of-getting-result-oriented-seo-from-an-agency).

## This is my code:

```
// Confirm if the user really wants to delete the productDialogResult result = MessageBox.Show("Do you really want to delete the product \"" + productName + "\"?", "Confirm product deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);if (result == DialogResult.OK){    MessageBox.Show("deleted");}
```

When I run the code and try to delete a product, [deleted](https://www.mindstick.com/forum/160487/how-to-remove-the-deleted-git-code-marker-in-scrollbar-in-visual-studio-2022) [never](https://yourviews.mindstick.com/view/290/zoos-prisons-for-beings-who-have-never-committed-a-crime) shows. On the MSDN page it says to use MessageBoxResult rather than DialogResult but [Visual Studio](https://www.mindstick.com/articles/12378/visual-studio-for-mac-is-out-of-beta-preview-now-officially-available) doesn't recognise MessageBoxResult, and I use DialogResult elsewhere in my code for an open file dialog. Obviously, that's not the proper way to check it.

## Replies

### Reply by Anonymous User

You must ask for DialogResult

.Yes

```
// Confirm if the user really wants to delete the productDialogResult result = MessageBox.Show("Do you really want to delete the product \"" +     productName + "\"?", "Confirm product deletion", MessageBoxButtons.YesNo,  MessageBoxIcon.Warning);if (result == DialogResult.Yes){    MessageBox.Show("deleted");} 
```


---

Original Source: https://www.mindstick.com/forum/1582/catching-messagebox-result

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
