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");
break;
case DialogResult.Retry:
MessageBox.Show("Retry Selected");
break;
case DialogResult.Ignore:
MessageBox.Show("Ignore Selected");
break;
default:
break;
}
}
No comments:
Post a Comment