分享
 
 
 

C#写的记事本

王朝c#·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

//notepad.cs

//==========================

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using System.IO;

namespace csnotepad

{

///

/// Summary description for Form1.

///

public class notepad : System.Windows.Forms.Form

{

private System.Windows.Forms.MainMenu mainMenu1;

private System.Windows.Forms.MenuItem menuItem1;

private System.Windows.Forms.MenuItem menuItem2;

private System.Windows.Forms.MenuItem menuItem3;

private System.Windows.Forms.MenuItem menuItem4;

private System.Windows.Forms.MenuItem menuItem5;

private System.Windows.Forms.MenuItem menuItem6;

private System.Windows.Forms.MenuItem menuItem7;

private System.Windows.Forms.MenuItem menuItem8;

private System.Windows.Forms.MenuItem menuItem9;

private System.Windows.Forms.MenuItem menuItem10;

private System.Windows.Forms.MenuItem menuItem11;

private System.Windows.Forms.MenuItem menuItem12;

private System.Windows.Forms.TextBox textBox1;

private System.Windows.Forms.MenuItem menuItem14;

private System.Windows.Forms.SaveFileDialog saveFileDialog1;

private System.Windows.Forms.MenuItem menuItem13;

private System.Windows.Forms.OpenFileDialog openFileDialog1;

private System.Windows.Forms.MenuItem menuItem15;

private System.Windows.Forms.MenuItem menuItem16;

///

/// Required designer variable.

///

private System.ComponentModel.Container components = null;

public notepad()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

//

// TODO: Add any constructor code after InitializeComponent call

//

}

///

/// Clean up any resources being used.

///

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

///

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

///

private void InitializeComponent()

{

this.mainMenu1 = new System.Windows.Forms.MainMenu();

this.menuItem1 = new System.Windows.Forms.MenuItem();

this.menuItem2 = new System.Windows.Forms.MenuItem();

this.menuItem3 = new System.Windows.Forms.MenuItem();

this.menuItem13 = new System.Windows.Forms.MenuItem();

this.menuItem4 = new System.Windows.Forms.MenuItem();

this.menuItem14 = new System.Windows.Forms.MenuItem();

this.menuItem5 = new System.Windows.Forms.MenuItem();

this.menuItem6 = new System.Windows.Forms.MenuItem();

this.menuItem7 = new System.Windows.Forms.MenuItem();

this.menuItem8 = new System.Windows.Forms.MenuItem();

this.menuItem9 = new System.Windows.Forms.MenuItem();

this.menuItem10 = new System.Windows.Forms.MenuItem();

this.menuItem11 = new System.Windows.Forms.MenuItem();

this.menuItem12 = new System.Windows.Forms.MenuItem();

this.menuItem15 = new System.Windows.Forms.MenuItem();

this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();

this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();

this.textBox1 = new System.Windows.Forms.TextBox();

this.menuItem16 = new System.Windows.Forms.MenuItem();

this.SuspendLayout();

//

// mainMenu1

//

this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {

this.menuItem1,

this.menuItem6,

this.menuItem11,

this.menuItem15});

//

// menuItem1

//

this.menuItem1.Index = 0;

this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {

this.menuItem2,

this.menuItem3,

this.menuItem13,

this.menuItem4,

this.menuItem14,

this.menuItem5});

this.menuItem1.Text = "文件";

//

// menuItem2

//

this.menuItem2.Index = 0;

this.menuItem2.Text = "&New";

this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);

//

// menuItem3

//

this.menuItem3.Index = 1;

this.menuItem3.Text = "&Open";

this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);

//

// menuItem13

//

this.menuItem13.Index = 2;

this.menuItem13.Text = "-";

//

// menuItem4

//

this.menuItem4.Index = 3;

this.menuItem4.Text = "&Save";

this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);

//

// menuItem14

//

this.menuItem14.Index = 4;

this.menuItem14.Text = "-";

//

// menuItem5

//

this.menuItem5.Index = 5;

this.menuItem5.Text = "Exit";

this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click_1);

//

// menuItem6

//

this.menuItem6.Index = 1;

this.menuItem6.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {

this.menuItem7,

this.menuItem8,

this.menuItem9,

this.menuItem10});

this.menuItem6.Text = "编辑";

//

// menuItem7

//

this.menuItem7.Index = 0;

this.menuItem7.Text = "&Cut";

this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);

//

// menuItem8

//

this.menuItem8.Index = 1;

this.menuItem8.Text = "&Copy";

this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);

//

// menuItem9

//

this.menuItem9.Index = 2;

this.menuItem9.Text = "Paste";

this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);

//

// menuItem10

//

this.menuItem10.Index = 3;

this.menuItem10.Text = "&Select All";

this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click);

//

// menuItem11

//

this.menuItem11.Index = 2;

this.menuItem11.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {

this.menuItem12,

this.menuItem16});

this.menuItem11.Text = "帮助";

//

// menuItem12

//

this.menuItem12.Index = 0;

this.menuItem12.Text = "About";

this.menuItem12.Click += new System.EventHandler(this.menuItem12_Click);

//

// menuItem15

//

this.menuItem15.Index = 3;

this.menuItem15.Text = "";

//

// saveFileDialog1

//

this.saveFileDialog1.FileName = "doc1";

//

// textBox1

//

this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;

this.textBox1.Multiline = true;

this.textBox1.Name = "textBox1";

this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;

this.textBox1.Size = new System.Drawing.Size(544, 321);

this.textBox1.TabIndex = 0;

this.textBox1.Text = "";

this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged_1);

//

// menuItem16

//

this.menuItem16.Index = 1;

this.menuItem16.Text = "General";

this.menuItem16.Click += new System.EventHandler(this.menuItem16_Click);

//

// notepad

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(544, 321);

this.Controls.AddRange(new System.Windows.Forms.Control[] {

this.textBox1});

this.ImeMode = System.Windows.Forms.ImeMode.Off;

this.Menu = this.mainMenu1;

this.Name = "notepad";

this.Text = "Notepad By 【孟宪会之精彩世界】";

this.Load += new System.EventHandler(this.Form1_Load);

this.ResumeLayout(false);

}

#endregion

///

/// The main entry point for the application.

///

[STAThread]

static void Main()

{

Application.Run(new notepad());

}

private void Form1_Load(object sender, System.EventArgs e)

{

}

private void menuItem3_Click(object sender, System.EventArgs e)

{

// for opening file

openFileDialog1.ShowDialog();

StreamReader sr = new StreamReader(openFileDialog1.FileName);

textBox1.Text = sr.ReadToEnd();

sr.Close();

}

private void menuItem7_Click(object sender, System.EventArgs e)

{

Clipboard.SetDataObject(textBox1.SelectedText);

textBox1.SelectedText="";

}

private void menuItem9_Click(object sender, System.EventArgs e)

{

textBox1.Paste();

}

private void textBox1_TextChanged(object sender, System.EventArgs e)

{

}

private void menuItem12_Click(object sender, System.EventArgs e)

{

Form2 helpnew = new Form2();

helpnew.Show();

}

private void textBox1_TextChanged_1(object sender, System.EventArgs e)

{

}

private void menuItem5_Click(object sender, System.EventArgs e)

{

}

private void menuItem5_Click_1(object sender, System.EventArgs e)

{

Dispose(true);

}

private void menuItem8_Click(object sender, System.EventArgs e)

{

textBox1.Copy();

}

private void menuItem10_Click(object sender, System.EventArgs e)

{

textBox1.SelectAll();

}

private void menuItem2_Click(object sender, System.EventArgs e)

{

textBox1.Clear();

}

private void menuItem4_Click(object sender, System.EventArgs e)

{

// for file save

saveFileDialog1.FileName = "*.txt";

//saveFileDialog1.FilterIndex ="*.txt";

saveFileDialog1.ShowDialog();

//MessageBox.Show (saveFileDialog1.FileName);

StreamWriter sw = new StreamWriter(saveFileDialog1.FileName);

sw.Write (textBox1.Text);

sw.Close();

}

private void menuItem16_Click(object sender, System.EventArgs e)

{

Form3 gen = new Form3 ();

gen.Show();

}

}

public class Form3 : System.Windows.Forms.Form

{

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.Container components = null;

public Form3()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

//

// TODO: Add any constructor code after InitializeComponent call

//

}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if(components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

//

// Form3

//

this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);

this.ClientSize = new System.Drawing.Size(292, 273);

this.Name = "Form3";

this.Text = "Form3";

this.Load += new System.EventHandler(this.Form3_Load);

}

#endregion

private void Form3_Load(object sender, System.EventArgs e)

{

}

}

public class Form2 : System.Windows.Forms.Form

{

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.Container components = null;

public Form2()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

//

// TODO: Add any constructor code after InitializeComponent call

//

}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if(components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

//

// Form2

//

this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);

this.ClientSize = new System.Drawing.Size(292, 273);

this.Name = "Form2";

this.Text = "Form2";

this.Load += new System.EventHandler(this.Form2_Load);

}

#endregion

private void Form2_Load(object sender, System.EventArgs e)

{

}

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有