I'm a real beginner on c# and everything. But I was trying to make my first program when I got this problem. I've done the "private void closeButton_Click(object sender, EventArgs e)" Wich says when click the custom close button it will show a confirm message.
But I want that one of the items on the menu strip named 'Exit', do the same thing as on that "private void closeButton_Click".
It's a short code, I could write a new message box and everything but it's got to be a way to simply repeat a code.
Here is the code
private void closeButton_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("Do you really want to exit?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)
{
Application.Exit();
}
else if (dialog == DialogResult.No)
{
//Close 'dialog'
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
closeButton_Click = true;
}
closeButton_Click(null, null);
in theexitToolStripMenuItem_Click
event? – Siyavash Hamdi