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.
Some of my previous articles are as follows: Connect
Multiple Events to a Single Event Handler in Windows Forms Using C#.Net and
VB.Net , Remove
Selected Item From Listbox C#.Net and VB.net , How
to add/move multiselected items from one listbox to another listbox in C#.Net
and VB.Net | C# multiple selection listbox move Using C#.Net , Transfer
Listbox Items to Another Listbox Using C#.Net and VB.Net | How to Move List Box
Items to another List Box in C# , Event
Handling in windows programming using C# | How To Add Events at run time in
windows application controls 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
0 comments:
Please let me know your view