The Types Of Message Boxes In C#

I am sorry guys , i have so many problems nowadays so I cannot concentrate on blogging, by the way I came through some forums posts and I really wanted to write something so today you will be learning the Types of Message Boxes in C# and the same types of Message Boxes are available in VB.NET .

What is a Message Box?
Shortly I can say Message Boxes are used to show Messages/Alerts to the user.

What are the types of Message Boxes?
The types of Message Boxes are something very important, if you want to display a message box you should know what is the type of the Message Box is going to be(ie:if you display "Cannot Convert" then that's a Error Message.
  1. Error Message Boxes.
  2. Information/Detail Message Boxes.
  3. Warning Message Boxes.
  4. Empty Message Boxes.
  5. Questioning Message Boxes.
  6. Exception Message Boxes.
Note : There are difference between Exception and Error .

Error : Error is something that stops the system from doing it or else we can say something that does not allow doing it.

Exception : Problems that occur during the run of a program or during the usage of a function or a statement.


Why to use Message Boxes?
There are many reasons of using Message Boxes in programs , mostly Message Boxes are used to warn,alert,show errors,ask questions.

How to use Message Boxes in C#?
well, now we are at the main point . everyone knows how to use message box whatever i will tell you how to use Message Boxes.

To show a normal message box.
Code:
MessageBox.Show("This is a normal messagebox");
Screenshot:
To show a title in message box.
Code:
            MessageBox.Show("This is a Message box with title", "Ultimate programming tutorials");
Screenshot:
Message With title
To show a message box with title and buttons.
Code:

                     MessageBox.Show("Message Box with title and buttons", "Ultimate programming tutorials", MessageBoxButtons.YesNoCancel);
Screenshot:
Message box with title and buttons
You can choose the set of buttons
can choose message box buttons
To show a message box with title,buttons & icon(type of message)
Code:
                     MessageBox.Show("Message Box with title,buttons and icon(type of messagebox)", "Ultimate programming tutorials", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
Screenshot:
message box With Title,Buttons And icon
You can choose the type of icon
can select message box icon

I wrote this in my own way i am sorry if there is anything wrong, i hope this has helped you in some ways , i will be writing more articles when i get rid of this depression etc etc , thank you.

Post a Comment

Note: Only a member of this blog may post a comment.