Question: Using C#, modify from MenuDialog to create a simple text editor. You need to add [STAThread] Before its Main method to make it work. In
Using C#, modify from MenuDialog to create a simple text editor. You need to add [STAThread]
Before its Main method to make it work.
In File menu, add option like New, Open, Save, Save As,Close, and Exit.
When the user selects Save As, display a SaveFileDialog to let the user to select a filename and whatever in the textbox should be saved to this file.
When the user selects Save, display a SaveFileDialog if the file has not been opened (created after the user clicked New or Close).
Both objects from OpenFileDialog and SaveFileDialog has a property called FileName. Define an instance variable of String type called filename to hold file name after an OpenFileDialog or SaveFileDialog is created. When the user clicks Save and filename is null, display SaveFileDialog.
When New and Close is selected, simply set textbox as empty string like textBox1.Text= and set filename as null.
Add a menu called Edit with three items like Cut, Copy, Paste
textBox1.selectedText returns the selected text from the textbox
Clipboard.SetText(textBox1.SelectedText) adds selectedText to Clipboard
Clipboard.GetText() returns what is in the clipboard.
When the user clicks cut or copy, set the clipboard with the text selected
When paste is clicked, set textBox1.Text as textBox1.Text.Substring(0, textBox1.SelectionStart) + what is in the clipboard + textBox1.Text.Substring(textBox1.SelectionStart + textBox1.SelectionLength);
When cut is clicked, it is almost same as above except what is in the clipboard will be empty string
Add another menu like Help with one or two option like who created the editor and version etc.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
