Open Visual Studio.
File -> New Project -> Windows Form Application.
Give design to Form as Below :-
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("What ?", "What", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
}
private void button2_Click(object sender, EventArgs e)
{
DialogResult dr = MessageBox.Show("What ?", "What", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
switch(dr)
{
case DialogResult.Yes:
{
this.Text = "[YES]";
break;
}
case DialogResult.No:
{
this.Text = "[NO]";
break;
}
}
}
private void button3_Click(object sender, EventArgs e)
{
DialogResult dr = MessageBox.Show("What ?", "What", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
switch (dr)
{
case DialogResult.Yes:
{
MessageBox.Show("You clicked Yes");
break;
}
case DialogResult.No:
{
MessageBox.Show("You clicked No");
break;
}
}
}
}
File -> New Project -> Windows Form Application.
Give design to Form as Below :-
Double Click on Click1 Button and write following code :-
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("What ?", "What", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
}
Double click on Click2 Button and Write following code :-
private void button2_Click(object sender, EventArgs e)
{
DialogResult dr = MessageBox.Show("What ?", "What", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
switch(dr)
{
case DialogResult.Yes:
{
this.Text = "[YES]";
break;
}
case DialogResult.No:
{
this.Text = "[NO]";
break;
}
}
}
Again double click on Click3 Button and write following code :-
private void button3_Click(object sender, EventArgs e)
{
DialogResult dr = MessageBox.Show("What ?", "What", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
switch (dr)
{
case DialogResult.Yes:
{
MessageBox.Show("You clicked Yes");
break;
}
case DialogResult.No:
{
MessageBox.Show("You clicked No");
break;
}
}
}
}
No comments:
Post a Comment