Operating effect:
Code:
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.ComponentModel;4 usingSystem.Data;5 usingSystem.Drawing;6 usingSystem.Linq;7 usingSystem.Text;8 usingSystem.Threading.Tasks;9 usingSystem.Windows.Forms;Ten One namespacefreenotes A { - Public Partial classNotepad:form - { the PublicNotePad () - { - InitializeComponent (); - } + - /// <summary> + ///Open File Event A /// </summary> at Private voidBtn_open_click (Objectsender, EventArgs e) - { -OpenFileDialog of =NewOpenFileDialog (); - -Of. DEFAULTEXT ="*.rtf"; - inOf. Filter ="RTF file (*.rtf) |*.rtf| All Files (*. *) |*.*"; - to if(Of. ShowDialog () = = DialogResult.OK && of. Filename.length >0) + { - Richtextbox1.loadfile (Of. FileName, richtextboxstreamtype.richtext); the } * } $ Panax Notoginseng /// <summary> - ///Save File Events the /// </summary> + Private voidBtn_save_click (Objectsender, EventArgs e) A { theSaveFileDialog SA =NewSaveFileDialog (); + -Sa. Title ="Save"; $ $Sa. FileName ="*.rtf"; - -Sa. Filter ="RTF file (*.rtf) |*.rtf| All Files (*. *) |*.*"; the -Sa. DEFAULTEXT ="*.rtf";Wuyi the if(SA. ShowDialog () = = DialogResult.OK && sa. Filename.length >0) - { Wu Richtextbox1.savefile (SA. FileName, richtextboxstreamtype.richtext); - } About } $ - /// <summary> - ///Font Events - /// </summary> A Private voidBtn_font_click (Objectsender, EventArgs e) + { theFontDialog FDA =NewFontDialog (); - $Fda. Showcolor =true; the the if(FDA. ShowDialog ()! =DialogResult.Cancel) the { theRichtextbox1.selectionfont =FDA. Font; -Richtextbox1.selectioncolor =FDA. Color; in } the } the About /// <summary> the ///emptying text Events the /// </summary> the Private voidBtn_clear_click (Objectsender, EventArgs e) + { - richtextbox1.clear (); the }Bayi } the}
WinForm Small Program NotePad