Tuesday, 13 May 2014

How to show error message in c# windows application | How to show Error & Warning Message Box in .NET

5/13/2014 - By Pranav Singh 0

When ever we create a windows application on that case in some places we needed to restrict user for entering some value or need to display error message box with error icon and ok button. So in this article i will show you how you can display a error message box in windows application using c# and VB.Net
If you are using try catch block on that case also you can use this message box to display the message box.

Some of my previous articles are as follows:


so here is the code for this article.

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;

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

        private void btnerror_Click(object sender, EventArgs e)
        {
            //Suppose we have error message "Sorry Please enter number only
            MessageBox.Show("Sorry Please enter number only", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
}

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

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

        Private Sub btnerror_Click(ByVal sender As Object, ByVal e As EventArgs)
            'Suppose we have error message "Sorry Please enter number only
            MessageBox.Show("Sorry Please enter number only", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.[Error])
        End Sub
    End Class
End Namespace

Now run the demo for output


now click on button to display the 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