(一).说明
功能类似Windows 操作系统自带的记事本. 一个WinForm记事本程序(包含主/下拉/弹出
菜单/打开保存对话框等控件用法以及记事本菜单事件的具体代码)
(二).图片示例


(三).代码
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Printing;
using System.Data;namespace 记事本
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class FormMain : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBoxEdit;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem8;
private System.Windows.Forms.MenuItem menuItem11;
private System.Windows.Forms.MenuItem menuItem14;
private System.Windows.Forms.MenuItem menuItem19;
private System.Windows.Forms.MenuItem menuItem22;
private System.Windows.Forms.MenuItem menuItemFile;
private System.Windows.Forms.MenuItem menuItemEdit;
private System.Windows.Forms.MenuItem menuItemFormat;
private System.Windows.Forms.MenuItem menuItemNew;
private System.Windows.Forms.MenuItem menuItemOpen;
private System.Windows.Forms.MenuItem menuItemSave;
private System.Windows.Forms.MenuItem menuItemSaveAs;
private System.Windows.Forms.MenuItem menuItemPageSet;
private System.Windows.Forms.MenuItem menuItemPrint;
private System.Windows.Forms.MenuItem menuItemExit;
private System.Windows.Forms.MenuItem menuItemUndo;
private System.Windows.Forms.MenuItem menuItemCut;
private System.Windows.Forms.MenuItem menuItemCopy;
private System.Windows.Forms.MenuItem menuItemPaste;
private System.Windows.Forms.MenuItem menuItemDel;
private System.Windows.Forms.MenuItem menuItemSelAll;
private System.Windows.Forms.MenuItem menuItemWordWrap;
private System.Windows.Forms.MenuItem menuItemFont;
private System.Windows.Forms.MenuItem menuItemColor;
const int MaxLenght=2000000;
private string currentFileName;
private System.Drawing.Printing.PrintDocument printDocument=new PrintDocument();
private bool needToSave;
public FormMain()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}