Saturday, 24 May 2014

How to show Error & Warning Message Box in .NET | C# MessageBox.Show Examples

5/24/2014 - By Pranav Singh 0

A MessageBox is a predefined dialog box that displays application-related information to the user. Message boxes are also used to request information from the user.

In this article i will show you how you can display the error message and warning message in windows application using C#.net and VB.Net.


So for this article first create a new windowsapplication.  Now add the two button one for displaying the error message and other for displaying the warning message.

C#.Net
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;
using System.Collections;

namespace ProjectDemo_Windows
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();          
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            MessageBox.Show("This is an error message.", "Error..", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("This is a warning message.", "Warning..", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
    }
}

VB.Net
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.Collections

Namespace ProjectDemo_Windows
    Partial Public Class Form1
        Inherits Form
        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub button1_Click_1(ByVal sender As Object, ByVal e As EventArgs)
            MessageBox.Show("This is an error message.", "Error..", MessageBoxButtons.OK, MessageBoxIcon.[Error])
        End Sub

        Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs)
            MessageBox.Show("This is a warning message.", "Warning..", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End Sub
    End Class
End Namespace

Now run the application

Error message


Warning Message



About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top