Zebra Notes: Open, Save, Save As, and Format with a Rich Text Box
Continue with the Notes Application.
Next we will write the code to implement New. The is a corresponding button on the toolbar and we will write the code to handle both events.
private void NewDocument()
{
// Delete everything from richtext box
// Remind to save.
Boolean cancel = AskToSave();
// If user did not select cancel, continue.
if (!cancel)
{
// Delete the contents of the rich text box.
richTextBox1.Text = "";
// Set the filename to untitled.
currentFileName = "Untitled";
// No changes so far.
changed = false;
// Show untitled in status bar.
toolStripStatusFilename.Text = currentFileName;
}
}
// Click both the new button and new menu item and write the code:
private void newToolStripButton_Click(object sender, EventArgs e)
{
// Delete everything from richtext box
NewDocument();
}
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
// Delete everything from richtext box
NewDocument();
}
Click Save All
at this point and run the program.
That's all! Congratulations on completing all of the lessons in csharp!