Hello there folks,
I'm trying to make myself more C# literate. I've decided to branch myself towards the GUI subject for the moment and get myself more familiar with dialog boxes and what not.
So for the moment, I've created a form which has a RichTextBox. And I've added a Close button which if the RichTextBox is empty, then the form will simply close. If the RichTextBox has any form of text or whatever inside it, then a dialog box will appear asking the user whether or not they want to save changes.
So far, this is my code:
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox.Text))
{
Close();
}
else
{
MessageBox.Show("Do you want to save changes?");
}
}
Now what my question to all of you generous people out there is, basically, How do I make the dialog box more dynamic by adding in a Cancel button and a Save button. Right now, the box does appear just fine, but I don't, of course, have any code which acknowledges the decision of the user. On Microsoft word or notepad, if someone types something in and then decides to exit, then a dialog box comes up asking whether or not they want to save changes, and if they do want to, then another dialog shows up which is a sort-of Windows Explorer and lets you choose a destination. But for now, I simply want to add a save, don't save and a cancel button on to the form.
How would I go about doing that?
Many thanks,
Usmaan