MessageBox.
Show("Do you want to save","Caption",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question);YesNoCancel Button
How should i add the functionality of this YesNoCancel button.
MessageBox.
Show("Do you want to save","Caption",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question);Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Nov 18, 2011, 7:46 AM
Try this...
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
DialogResult result;
result = MessageBox.Show("Are you sure you want to exit?", "Application 1", MessageBoxButtons.YesNoCancel);
if (result == DialogResult.No)
{
MessageBox.Show("App won´t close");
}
if (result == DialogResult.Yes)
{
this.Dispose();
}
}
}
}
Thanks
Satyapriya NayakPosted Nov 18, 2011, 7:50 AM
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
switch (MessageBox.Show("Do you want to create a new file?", "YesNoCancel", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
{
case DialogResult.Yes:
// "Yes" processing
break;
case DialogResult.No:
// "No" processing
break;
case DialogResult.Cancel:
// "Cancel" processing
break;
}
}
}
}
Gomathi PalaniswamyPosted Nov 18, 2011, 7:45 AM
{
MessageBox.Show("Yes");
}
Datta KharadPosted Nov 18, 2011, 7:43 AM
DialogResult result= MessageBox.Show("Do you want to save...!!!", "Caption", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
switch (result)
{
case DialogResult.Yes:
{
this.Text = "Here your Save operation";
break;
}
case DialogResult.No:
{
this.Text = "Here your Without saving";
break;
}
case DialogResult.Cancel:
{
this.Text = "Here your do nothing operation";
break;
}
}