Define Visual C#.Net

C# Form Control

C# Label Control

C# TextBox Control

C# Button Control

C# RadioButton Control

C# CheckBox Control

C# CheckListBox

C# ListBox Control

C# ComboBox Control

C# LinkLabel Control

C# DateTime DataType

C# DateTimePicker

C# NumericUpDown

C# RandomNumber

C# PictureBox

C# ProgressBar

C# Timer Control

C# ToolTip

C# TabControl

C# RichTextBox

C# MessageBox

C# Menu Control

C# Toolbars

C# Dialogs Box

Page Stats

Visitor: 234

MessageBox Control in C#.Net

The System.Windows.Forms.MessageBox is a static class that is used to show message boxes for prompting, confirmation and warning users.

MessageBox.Show("Hello World!");
MessageBox.Show("Hello World!", "A Message");
MessageBox.Show("Hello World","A Message", MessageBoxButtons.OKCancel);

The table below shows the members of the MessageBoxButtons enumeration.
AbortRetryIgnore
OK
OKCancel
RetryCancel
YesNo
YesNoCancel

DialogResult result = MessageBox.Show("What is your choice?"); if (result == DialogResult.Yes) { //You pressed the Yes button } if (result == DialogResult.No) { //You pressed the No button }

MessageBox.Show("Hello World!", "A Message", MessageBoxButtons.OK, //* MessageBoxIcon.Information);

Asterisk
Information - Used when showing information to the user.

Error Hand Stop - Used when showing error messages.
Exclamation
Warning - Used when showing warning messages.
Question - Used when asking a question to the user.
None - For no Icon

MessageBox.Show("Hello World!", "A Message", MessageBoxButtons.OKCancel,MessageBoxDefaultButton.Button1);