First Use the menu and toolbar controls, Notepad's tool menu bar directly with the MenuStrip control, and then right-select Insert Standard items, simple menu bar function button will be automatically added,
Add a bottom toolbar with Statustrip, which can place multiple controls such as a text drop-down menu, add two controls that display text, and use it as a record to display the number of characters in Notepad.
Currently, only the functions and exits in the Edit drop-down list are implemented.
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespaceMenu Control { Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); } Private voidExit Xtoolstripmenuitem_click (Objectsender, EventArgs e) { This. Close ();//mouse Click to implement the Exit } Private voidUndo Utoolstripmenuitem_click (Objectsender, EventArgs e) {Textbox1.undo ();//mouse Click to implement the input text revocation } Private voidShear Ttoolstripmenuitem_click (Objectsender, EventArgs e) {textbox1.cut ();//mouse click to achieve text cut } Private voidCopy Ctoolstripmenuitem_click (Objectsender, EventArgs e) {textbox1.copy ();//mouse click to achieve text copy } Private voidPaste Ptoolstripmenuitem_click (Objectsender, EventArgs e) {textbox1.paste ();//mouse click to implement text pasting } Private voidSelect All Atoolstripmenuitem_click (Objectsender, EventArgs e) {Textbox1.selectall ();//mouse Click to achieve the full selection of text } Private voidtextBox1_TextChanged (Objectsender, EventArgs e) { strings =textBox1.TextLength.ToString (); //record and display the number of characters, first assign the length of the Notepad text to the variable s in the form of a string Toolstripstatuslabel2.text=s; //Bottom menu bar text control text value equals the length of the Notepad text } }}
Simple function Making of Notepad