資源簡介
c#的一個擁有多窗口MDI的記事本小小程序,基本實現了記事本所有功能,課堂程序,僅供參考,共同進步。

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.IO;
namespace?Note
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????
????????private?void?mnuNew_Click(object?sender?EventArgs?e)
????????{
????????????FrmChild?frmCld?=?new?FrmChild();
????????????frmCld.MdiParent?=?this;
????????????Button?btn?=?new?Button();
????????????btn.AutoSize?=?true;
????????????btn.Height?=?25;
????????????btn.Width?=?60;
????????????btn.Margin?=?btn.Padding?=?new?Padding(0);
????????????btn.Text?=?“無標題“;
????????????btn.Font?=?new?Font(“宋體“9);
????????????flowLayoutPanel1.Controls.Add(btn);
????????????btn.Click+=new?EventHandler(btn_Click);
????????????btn.Tag?=?frmCld;
????????????frmCld.Tag?=?btn;
????????????frmCld.Show();//新建和后面的打開子窗口,Show出來的時候都包含激活,如果寫在new?Button前面的話,激活的活動子窗口還沒有跟它對應的Button
????????}
????????private?void?mnuOpen_Click(object?sender?EventArgs?e)
????????{??????
????????????DialogResult?result?=?openFileDialog1.ShowDialog();
????????????if?(result?!=?System.Windows.Forms.DialogResult.OK)
????????????{
????????????????return;
????????????}
????????????string?path?=?openFileDialog1.FileName;
????????????FrmChild?frmCld?=?new?FrmChild();
????????????frmCld.MdiParent?=?this;
????????????frmCld.Text?=?path;
????????????frmCld.textBox1.Text?=?File.ReadAllText(path?Encoding.Default);
????????????Button?btn?=?new?Button();
????????????btn.AutoSize?=?true;
????????????btn.Height?=?25;
????????????btn.Width?=?60;
????????????btn.Margin?=?btn.Padding?=?new?Padding(0);
????????????btn.Text?=?Path.GetFileName(path);
????????????btn.Font?=?new?Font(“宋體“?9);
????????????flowLayoutPanel1.Controls.Add(btn);
????????????btn.Click?+=?new?EventHandler(btn_Click);
????????????btn.Tag?=?frmCld;
????????????frmCld.Tag?=?btn;
????????????frmCld.Show();
????????}
????????private?void?btn_Click(object?sender?EventArgs?e)
????????{
????????????Form?current?=?(sender?as?Button).Tag?as?Form;
????????????current.Activate();
????????????foreach?(Button?btn?in?flowLayoutPanel1.Controls)
????????????{
????????????????btn.Flatstyle?=?Flatstyle.System;
????????????}
????????????(sender?as?Button).Flatstyle?=?Flatstyle.Flat;
????????}
????????private?void?mnuPageSet_Click(object?sender?EventArgs?e)
????????{
????????????pageSetupDialog1.Document?=?printDocument1;
????????????pageSetupDialog1.EnableMetric?=?true;???//解決頁邊距單位轉換問題
????????????pageSetupDialog1.ShowDialog();?
????????}
????????private?void?mnuPrint_Click(object?sender?EventArgs?e)
????????{
????????????printDialog1.Document?=?printDocument1;
????????????DialogResult?result?=?printDialog1.ShowDialog();
????????????if?(result?!=?System.Windows.Forms.DialogResult.OK)
????????????{
?????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-10-28?15:32??記事本\
?????目錄???????????0??2014-10-28?15:32??記事本\Note\
?????文件???????33371??2014-10-28?11:37??記事本\Note\Form1.Designer.cs
?????文件???????11841??2014-10-28?11:37??記事本\Note\Form1.cs
?????文件???????16455??2014-10-28?11:37??記事本\Note\Form1.resx
?????文件????????5405??2014-10-28?11:18??記事本\Note\FrmChild.Designer.cs
?????文件????????5552??2014-10-28?11:18??記事本\Note\FrmChild.cs
?????文件????????6216??2014-10-28?11:18??記事本\Note\FrmChild.resx
?????文件????????5192??2014-10-28?11:27??記事本\Note\Note.csproj
?????文件?????????485??2014-10-28?11:18??記事本\Note\Program.cs
?????目錄???????????0??2014-10-28?15:32??記事本\Note\Properties\
?????文件????????1364??2014-10-28?11:18??記事本\Note\Properties\AssemblyInfo.cs
?????文件????????2832??2014-10-28?11:18??記事本\Note\Properties\Resources.Designer.cs
?????文件????????5612??2014-10-28?11:18??記事本\Note\Properties\Resources.resx
?????文件????????1102??2014-10-28?11:18??記事本\Note\Properties\Settings.Designer.cs
?????文件?????????249??2014-10-28?11:18??記事本\Note\Properties\Settings.settings
?????文件????????8377??2014-10-28?15:05??記事本\Note\Replace.Designer.cs
?????文件????????2797??2014-10-28?15:15??記事本\Note\Replace.cs
?????文件????????5814??2014-10-28?15:05??記事本\Note\Replace.resx
?????目錄???????????0??2014-10-28?15:32??記事本\Note\bin\
?????目錄???????????0??2014-10-28?15:32??記事本\Note\bin\Debug\
?????文件???????43008??2014-10-28?15:08??記事本\Note\bin\Debug\Note.exe
?????文件???????73216??2014-10-28?15:08??記事本\Note\bin\Debug\Note.pdb
?????文件???????14328??2014-10-28?15:09??記事本\Note\bin\Debug\Note.vshost.exe
?????文件?????????490??2007-07-21?01:33??記事本\Note\bin\Debug\Note.vshost.exe.manifest
?????文件????????6329??2014-10-28?11:18??記事本\Note\frmFind.Designer.cs
?????文件????????2413??2014-10-28?11:18??記事本\Note\frmFind.cs
?????文件????????5814??2014-10-28?11:18??記事本\Note\frmFind.resx
?????文件????????3742??2014-10-28?11:27??記事本\Note\frmGoto.Designer.cs
?????文件?????????987??2014-10-28?11:28??記事本\Note\frmGoto.cs
?????文件????????5814??2014-10-28?11:27??記事本\Note\frmGoto.resx
............此處省略20個文件信息
- 上一篇:C# 最短路徑 Dijkstra算法實現
- 下一篇:c# 自動序號生成
評論
共有 條評論