I am making a notepad program and I am having a problem; On my New
Button, I have this code:
private void New()
{
if (us == true)
{
DialogResult dr = MessageBox.Show("Do you want to save changes to: " + filepath, "Save Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
if (dr == DialogResult.Yes)
Save();
else if (dr == DialogResult.No)
{
filename = null;
undoToolStripMenuItem.Enabled = false;
undoToolStripMenuItem1.Enabled = false;
redoToolStripMenuItem.Enabled = false;
redoToolStripMenuItem1.Enabled = false;
us = false;
Form1.ActiveForm.Text = "Untitled - PadNotePro";
richTextBox1.Clear();
}
else if (dr == DialogResult.Cancel)
Close();
}
else
{
filename = null;
undoToolStripMenuItem.Enabled = false;
undoToolStripMenuItem1.Enabled = false;
redoToolStripMenuItem.Enabled = false;
redoToolStripMenuItem1.Enabled = false;
Form1.ActiveForm.Text = "Untitled - PadNotePro";
richTextBox1.Clear();
}
}
us
means un-saved, it is to see if it is saved, if us = true, it is not saved.
When I click no on my DialogBox
, it runs this code:
else if (dr == DialogResult.No)
{
filename = null;
undoToolStripMenuItem.Enabled = false;
undoToolStripMenuItem1.Enabled = false;
redoToolStripMenuItem.Enabled = false;
redoToolStripMenuItem1.Enabled = false;
us = false;
Form1.ActiveForm.Text = "Untitled - PadNotePro";
richTextBox1.Clear();
}
What I am having a problem with, is the: Form1.ActiveForm.Text = "Untitled - PadNotePro";
, it seems like it is skipping that line of code. I think it has something to do with the MessageBox
, but can't figure it out. Does anyone know why?
EDIT:
I think it might have something to do with the Form
not being active at the time.