This article will show you how you can display confirmation
message in a windows application using c#.net. In this we will user have
pressed YES or NO.
Some of my previous articles are as follows: Error
Handling in Windows Application Using C#.Net, Restrict
User to Enter Only Negative, Non-Negative and Decimal Number in TextBox Using
C#.Net in Windows Application, Dynamically
Add textbox control on button click in windows application using C#.net and
VB.net, Paging
in DataGridview Using C#.Net In Windows Application, Show
Progressbar While Moving Folder File From One Directory To Other Using C#.Net
In Windows Application, How
to Create Column Chart in Windows Application Using C#.Net.
So first we will create a new windows application and add a
button control and label controls to display data.
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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void Form1_Load(object
sender, EventArgs e)
{
}
private
void button1_Click(object
sender, EventArgs e)
{
DialogResult
result1 = MessageBox.Show("Please press YES or NO", "Question...", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if
(result1 == DialogResult.Yes)
{
label2.Text = DialogResult.Yes.ToString();
}
else
{
label2.Text = DialogResult.No.ToString();
}
}
}
}
|
In above code I have captured the yes no control click event and then as per selection yes no have been displayed.
Now we have done run the application to check the output.
0 comments:
Please let me know your view