Custom Search

Thursday, July 17, 2008

MessageBox using AbortRetryIgnore Button in C#

This example is very similar to the previous one where I showed you how to write an example using the YesNo MessageBox. Here the only difference is that the MessageBox is with the AbortRetryIgnore Button.

Ok, now I will proceed to write a small example of this. Basicly what I want to do here is to distinguish between the three different types of buttons that this type of MessageBox contains. Here I will use a swith statment because I find it a little more correct.
So the complete C# code is this:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

private void button1_Click(object sender, EventArgs e)


DialogResult result;

result = MessageBox.Show("The Cd drive is not ready. \nReinsert and try again!", "Error on Drive", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);

switch (result)


case DialogResult.Abort:

MessageBox.Show("Abort Selected");


case DialogResult.Retry:

MessageBox.Show("Retry Selected");


case DialogResult.Ignore:

MessageBox.Show("Ignore Selected");






Result when executing:

No comments: