- <font size="4" color="#ff0000"><strong><u>没找到上传压缩文件的按钮,只好把源代码上传到这里了.<img alt="" src="/Editor/FCKeditor/editor/images/smiley/msn/regular_smile.gif"></u></strong></font>
没找到上传压缩文件的按钮,只好把源代码上传到这里了.
- <strong><u><font size="4" color="#ff0000">注释很详细哦</font></u></strong>
注释很详细哦
- <font size="4" color="#ff0000"><strong><u>Form1.cs </u></strong></font><strong><u><font size="4" color="#ff0000">************************************************</font></u></strong>
Form1.cs ************************************************
- using System;
-
- using System.Collections.Generic;
-
- using System.ComponentModel;
-
- using System.Data;
-
- using System.Drawing;
-
- using System.Text;
-
- using System.Windows.Forms;
-
- using System.IO;
-
-
-
- namespace txttest
-
- {
-
- public partial class Form1 : Form
-
- {
-
- public Form1()
-
- {
-
- InitializeComponent();
-
- }
-
-
-
-
-
-
-
-
-
- #region 定义变量
-
- public bool txtchange;
-
- public bool save;
-
- Search sea;
-
- Change cha;
-
- #endregion
-
- #region 文件菜单
-
-
-
- private void MnuNew_Click(object sender, EventArgs e)
-
- {
-
- NewFile();
-
- }
-
-
-
- private void MnuOpen_Click(object sender, EventArgs e)
-
- {
-
- OpenFile();
-
- }
-
-
-
- private void MnuSave_Click(object sender, EventArgs e)
-
- {
-
- save = true;
-
- SaveFile();
-
- }
-
-
-
- private void MnuSaveAs_Click(object sender, EventArgs e)
-
- {
-
- save = false;
-
- SaveFile();
-
- }
-
-
-
- private void MnuPageSetup_Click(object sender, EventArgs e)
-
- {
-
- pageSetupDialog1 = new PageSetupDialog();
-
- pageSetupDialog1.Document = printDocument;
-
- pageSetupDialog1.ShowDialog();
-
- }
-
-
-
- private void MnuPringPreview_Click(object sender, EventArgs e)
-
- {
-
- printPreviewDialog.ShowDialog();
-
- }
-
-
-
- private void MnuPrint_Click(object sender, EventArgs e)
-
- {
-
- printDocument.DocumentName = richTextBox1.Text;
-
- printDialog.Document = printDocument;
-
- if (printDialog.ShowDialog() == DialogResult.OK)
-
- {
-
-
-
- try
-
- {
-
- printDocument.Print();
-
- }
-
- catch(Exception ex)
-
- {
-
- MessageBox.Show(ex.Message);
-
- }
-
- }
-
- }
-
-
-
- private void MnuExit_Click(object sender, EventArgs e)
-
- {
-
- DialogResult res;
-
- res = MessageBox.Show("确定退出记事本?", "退出提示", MessageBoxButtons.OKCancel);
-
- if (res == DialogResult.OK)
-
- {
-
-
-
- if (txtchange)
-
- {
-
- DialogResult re;
-
- re = MessageBox.Show("内容已更改/n是否保存?", "保存提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
-
-
-
- if (re == DialogResult.Yes)
-
- {
-
- if (saveFileDialog.ShowDialog() == DialogResult.OK)
-
- {
-
-
-
- richTextBox1.SaveFile(saveFileDialog.FileName, RichTextBoxStreamType.PlainText);
-
- Close();
-
-
-
- }
-
- else
-
- return;
-
- }
-
- else if (re == DialogResult.No)
-
- {
-
- Close();
-
- }
-
- else
-
- {
-
- return;
-
- }
-
- }
-
- else
-
- Close();
-
- }
-
- else
-
-
-
- return;
-
- }
-
-
-
-
-
- private void richTextBox1_KeyPress_1(object sender, KeyPressEventArgs e)
-
- {
-
-
-
- if (e.KeyChar.ToString() != "")
-
-
-
- txtchange = true;
-
- }
-
- #endregion
-
- #region 编辑菜单
-
-
-
- private void MnuRemove_Click(object sender, EventArgs e)
-
- {
-
- richTextBox1.Undo();
-
- }
-
-
-
- private void MnuCut_Click(object sender, EventArgs e)
-
- {
-
- richTextBox1.Cut();
-
- }
-
-
-
- private void MnuCopy_Click(object sender, EventArgs e)
-
- {
-
- richTextBox1.Copy();
-
- }
-
-
-
- private void MnuStick_Click(object sender, EventArgs e)
-
- {
-
- richTextBox1.Paste();
-
- }
-
-
-
- private void MnuDel_Click(object sender, EventArgs e)
-
- {
-
- richTextBox1.SelectedText = "";
-
- }
-
-
-
- private void MnuSearch_Click(object sender, EventArgs e)
-
- {
-
-
-
- sea = new Search();
-
-
-
- sea.Show();
-
- }
-
-
-
- private void MnuSearchNext_Click(object sender, EventArgs e)
-
- {
-
-
-
- sea = new Search();
-
-
-
- sea.Show();
-
- }
-
-
-
- private void MnuSwap_Click(object sender, EventArgs e)
-
- {
-
-
-
- cha = new Change();
-
-
-
- cha.Show();
-
- }
-
-
-
- private void MnuTurn_Click(object sender, EventArgs e)
-
- {
-
- Go go = new Go();
-
- go.Show();
-
- }
-
-
-
- private void MnuFull_Click(object sender, EventArgs e)
-
- {
-
- richTextBox1.SelectAll();
-
- }
-
-
-
- private void MnuTime_Click(object sender, EventArgs e)
-
- {
-
- richTextBox1.Text += DateTime.Now.ToString();
-
- }
-
-
-
- #endregion
-
-
-
- #region 格式菜单
-
-
-
- private void MnuLineWrap_Click(object sender, EventArgs e)
-
- {
-
- if (richTextBox1.WordWrap)
-
- {
-
- richTextBox1.WordWrap = false;
-
- }
-
- else
-
- richTextBox1.WordWrap = true;
-
- }
-
-
-
- private void MnuFont_Click(object sender, EventArgs e)
-
- {
-
- FontDialog ftDg = new FontDialog();
-
- ftDg.ShowColor = true;
-
- ftDg.AllowScriptChange = true;
-
- ftDg.AllowVectorFonts = true;
-
- ftDg.ShowEffects = true;
-
-
-
- if (ftDg.ShowDialog() == DialogResult.OK)
-
- {
-
- richTextBox1.Font = ftDg.Font;
-
- richTextBox1.ForeColor = ftDg.Color;
-
- }
-
- }
-
- #endregion
-
- #region 查看菜单
-
-
-
- private void MnuStatusBar_Click(object sender, EventArgs e)
-
- {
-
- if (statusStrip1.Visible)
-
- {
-
- statusStrip1.Visible = false;
-
- }
-
- else
-
- {
-
- statusStrip1.Visible = true;
-
- }
-
- }
-
- #endregion
-
- #region 帮助菜单
-
-
-
- private void MnuTheme_Click(object sender, EventArgs e)
-
- {
-
- System.Diagnostics.Process.Start(@"c:/windows/help/notepad.chm");
-
- }
-
-
-
- private void MnuAbout_Click(object sender, EventArgs e)
-
- {
-
-
-
- About ab = new About();
-
-
-
- ab.label5.Text = "制作:/n/n汪祖华-李涛-孙远飞-闫兴/n/n技术支持:鄢涛老师";
-
-
-
- ab.Show();
-
- }
-
- #endregion
-
-
-
- #region 被调用的方法
-
-
-
- private void NewFile()
-
- {
-
-
-
- if (txtchange)
-
- {
-
-
-
- DialogResult re;
-
- re = MessageBox.Show("内容已更改,是否保存?", "保存提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
-
-
-
- switch (re)
-
- {
-
- case DialogResult.Yes:
-
- {
-
-
-
- if (saveFileDialog.ShowDialog() == DialogResult.OK)
-
- {
-
-
-
- richTextBox1.SaveFile(saveFileDialog.FileName, RichTextBoxStreamType.PlainText);
-
-
-
- richTextBox1.Clear();
-
- }
-
- else
-
- return;
-
- }
-
- break;
-
- case DialogResult.No:
-
- richTextBox1.Clear();
-
- break;
-
- case DialogResult.Cancel:
-
- break;
-
- }
-
- }
-
- else
-
- richTextBox1.Clear();
-
- }
-
-
-
- private void OpenFile()
-
- {
-
-
-
- if (txtchange)
-
- {
-
-
-
- DialogResult re;
-
- re = MessageBox.Show("内容已更改,是否保存?", "保存提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
-
-
-
- switch (re)
-
- {
-
- case DialogResult.Yes:
-
- {
-
-
-
-
-
- if (saveFileDialog.ShowDialog() == DialogResult.OK)
-
- {
-
-
-
- richTextBox1.SaveFile(saveFileDialog.FileName, RichTextBoxStreamType.PlainText);
-
-
-
- OpenFile_2();
-
- }
-
- }
-
- break;
-
- case DialogResult.No:
-
- {
-
- OpenFile_2();
-
- }
-
- break;
-
- case DialogResult.Cancel:
-
- break;
-
- }
-
- }
-
- else
-
- {
-
- OpenFile_2();
-
- }
-
- }
-
-
-
- private void SaveFile()
-
- {
-
-
-
- if (save == true)
-
- {
-
-
-
- if (saveFileDialog.ShowDialog() == DialogResult.OK)
-
- {
-
-
-
- richTextBox1.SaveFile(saveFileDialog.FileName, RichTextBoxStreamType.PlainText);
-
- }
-
- else
-
- return;
-
- }
-
- else
-
- {
-
-
-
- if (saveAsFileDialog.ShowDialog() == DialogResult.OK)
-
- {
-
-
-
- richTextBox1.SaveFile(saveAsFileDialog.FileName, RichTextBoxStreamType.PlainText);
-
- }
-
- else
-
- return;
-
- }
-
- }
-
- private void OpenFile_2()
-
- {
-
-
-
- if (openFileDialog.ShowDialog() == DialogResult.OK)
-
- {
-
-
-
- Text = openFileDialog.FileName;
-
-
-
- richTextBox1.LoadFile(openFileDialog.FileName, RichTextBoxStreamType.PlainText);
-
- }
-
- }
-
- #endregion
-
-
-
- #region 其他事件
-
-
-
- private void richTextBox1_MouseMove_1(object sender, MouseEventArgs e)
-
- {
-
-
-
- toolLabel_Mouse.Text = e.X.ToString() + "." + e.Y.ToString();
-
- }
-
-
-
- private void timer1_Tick(object sender, EventArgs e)
-
- {
-
-
-
- toolLabel_Time.Text = DateTime.Now.ToString();
-
-
-
- }
-
-
-
- private void Form1_Load(object sender, EventArgs e)
-
- {
-
-
-
- toolLabel_Opentime.Text = DateTime.Now.ToString("MM-dd H:mm:ss");
-
- }
-
- #endregion
-
- #region richtextbox 右键菜单
-
-
-
- private void 撤销ToolStripMenuItem_Click(object sender, EventArgs e)
-
- {
-
- richTextBox1.Undo();
-
- }
-
-
-
- private void 复制ToolStripMenuItem_Click(object sender, EventArgs e)
-
- {
-
- richTextBox1.Copy();
-
- }
-
-
-
- private void 剪切ToolStripMenuItem_Click(object sender, EventArgs e)
-
- {
-
- richTextBox1.Cut();
-
- }
-
-
-
- private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
-
- {
-
- richTextBox1.Paste();
-
- }
-
-
-
- private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
-
- {
-
- richTextBox1.SelectedText = "";
-
- }
-
- #endregion
-
- #region 菜单 右键菜单
-
-
-
- private void 关于记事本ToolStripMenuItem_Click(object sender, EventArgs e)
-
- {
-
- About ab = new About();
-
- ab.label5.Text = "制作:/n/n汪祖华-李涛-孙远飞-闫兴/n/n技术支持:鄢涛老师";
-
- ab.Show();
-
- }
-
- #endregion
-
- }
-
- }
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace txttest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/******************************************************************/
/******************************************************************/
/******************************************************************/
/******************************************************************/
#region 定义变量
public bool txtchange; //定义用于检查文本是否改变的变量
public bool save; //定义bool类型Save判断用户选择得是SaveFile()还是SaveAsFile()
Search sea; //声明查找的成员
Change cha; //声明替换的成员
#endregion
#region 文件菜单
//新建
private void MnuNew_Click(object sender, EventArgs e)
{
NewFile();
}
//打开
private void MnuOpen_Click(object sender, EventArgs e)
{
OpenFile();
}
//保存
private void MnuSave_Click(object sender, EventArgs e)
{
save = true;
SaveFile();
}
//另存为
private void MnuSaveAs_Click(object sender, EventArgs e)
{
save = false;
SaveFile();
}
//页面设置
private void MnuPageSetup_Click(object sender, EventArgs e)
{
pageSetupDialog1 = new PageSetupDialog(); //初始化pageSetupDialog1的新实例
pageSetupDialog1.Document = printDocument; //获取或设置一个值,指示从中获取页面设置
pageSetupDialog1.ShowDialog(); //弹出页面设置对话框
}
//打印预览
private void MnuPringPreview_Click(object sender, EventArgs e)
{
printPreviewDialog.ShowDialog(); //调用系统的打印预览对话框
}
//打印
private void MnuPrint_Click(object sender, EventArgs e)
{
printDocument.DocumentName = richTextBox1.Text; //获取打印得文档名
printDialog.Document = printDocument; //打印对话框
if (printDialog.ShowDialog() == DialogResult.OK) //点击打印的确定按钮==OK
{
//异常处理
try
{
printDocument.Print(); //try 打印时是否出错
}
catch(Exception ex)
{
MessageBox.Show(ex.Message); //出错则弹出系统定义的错误信息
}
}
}
//退出
private void MnuExit_Click(object sender, EventArgs e)
{
DialogResult res; //实例化对话框的结果按钮为res=OK,Cancle
res = MessageBox.Show("确定退出记事本?", "退出提示", MessageBoxButtons.OKCancel);
if (res == DialogResult.OK)
{
//判断文件是否修改过 包括空格
if (txtchange)
{
DialogResult re; //实例化对话框的结果按钮为res=Yes,No,Cancle
re = MessageBox.Show("内容已更改/n是否保存?", "保存提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (re == DialogResult.Yes)
{
if (saveFileDialog.ShowDialog() == DialogResult.OK)//点击保存文件对话框得OK时执行下面
{
//获取将要保存的文件名,并将其中的文件获取并保存
richTextBox1.SaveFile(saveFileDialog.FileName, RichTextBoxStreamType.PlainText);
Close(); //保存并退出
}
else
return; //返回至编辑界面
}
else if (re == DialogResult.No)
{
Close(); //不保存退出
}
else
{
return; //返回至编辑界面
}
}
else
Close(); //文件没有被修改过,直接退出
}
else
return; //返回至编辑界面
}
//检查txtbox中内容是否有更改
private void richTextBox1_KeyPress_1(object sender, KeyPressEventArgs e)
{
//获取键盘的按键值
if (e.KeyChar.ToString() != "")
//若获取到键盘按键,则txtchange=TRUE
txtchange = true;
}
#endregion
#region 编辑菜单
//撤销
private void MnuRemove_Click(object sender, EventArgs e)
{
richTextBox1.Undo(); //系统的撤销方法
}
//剪切
private void MnuCut_Click(object sender, EventArgs e)
{
richTextBox1.Cut(); //系统的剪切方法
}
//复制
private void MnuCopy_Click(object sender, EventArgs e)
{
richTextBox1.Copy(); //系统的复制方法
}
//粘贴
private void MnuStick_Click(object sender, EventArgs e)
{
richTextBox1.Paste(); //系统的粘贴方法
}
//删除
private void MnuDel_Click(object sender, EventArgs e)
{
richTextBox1.SelectedText = ""; //将选定的文本设为空
}
//查找
private void MnuSearch_Click(object sender, EventArgs e)
{
//实例Search的成员sea
sea = new Search();
//弹出查找对话框
sea.Show();
}
//查找下一个
private void MnuSearchNext_Click(object sender, EventArgs e)
{
//实例Search的成员sea
sea = new Search();
//弹出查找对话框
sea.Show();
}
//替换
private void MnuSwap_Click(object sender, EventArgs e)
{
//实例Change的成员cha
cha = new Change();
//弹出查找下一个对话框
cha.Show();
}
//转到
private void MnuTurn_Click(object sender, EventArgs e)
{
Go go = new Go();
go.Show();
}
//全选
private void MnuFull_Click(object sender, EventArgs e)
{
richTextBox1.SelectAll(); //系统全选的方法
}
//时间 -- 日期
private void MnuTime_Click(object sender, EventArgs e)
{
richTextBox1.Text += DateTime.Now.ToString(); //添加系统当前时间
}
#endregion
#region 格式菜单
//自动换行
private void MnuLineWrap_Click(object sender, EventArgs e)
{
if (richTextBox1.WordWrap) //WordWrap为richTextBox的换行属性
{
richTextBox1.WordWrap = false; //true时为自动换行
}
else
richTextBox1.WordWrap = true;
}
//字体
private void MnuFont_Click(object sender, EventArgs e)
{
FontDialog ftDg = new FontDialog(); //实例化字体设置
ftDg.ShowColor = true; //设置字体颜色
ftDg.AllowScriptChange = true; //获取外部字符集
ftDg.AllowVectorFonts = true; //斜体字
ftDg.ShowEffects = true; //删除线,下划线,字体颜色
if (ftDg.ShowDialog() == DialogResult.OK)
{
richTextBox1.Font = ftDg.Font;
richTextBox1.ForeColor = ftDg.Color;
}
}
#endregion
#region 查看菜单
//状态栏
private void MnuStatusBar_Click(object sender, EventArgs e)
{
if (statusStrip1.Visible) //状态栏的属性Visible
{
statusStrip1.Visible = false; //true时为显示状态栏
}
else
{
statusStrip1.Visible = true;
}
}
#endregion
#region 帮助菜单
//帮助主题
private void MnuTheme_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(@"c:/windows/help/notepad.chm"); //调出系统目录下得记事本帮助文档
}
//关于记事本
private void MnuAbout_Click(object sender, EventArgs e)
{
//实例化About类成员ab
About ab = new About();
//为成员控件赋值
ab.label5.Text = "制作:/n/n汪祖华-李涛-孙远飞-闫兴/n/n技术支持:鄢涛老师";
//调出成员对话框
ab.Show();
}
#endregion
#region 被调用的方法
//新建文件的方法
private void NewFile()
{
//判断文件是否修改过 包括空格
if (txtchange)
{
//实例化对话框的成员re为对话框的按钮Yes,No,Cancle
DialogResult re;
re = MessageBox.Show("内容已更改,是否保存?", "保存提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
//判断所选按钮
switch (re)
{
case DialogResult.Yes: //若选择yes弹出保存对话框
{
//若选择保存按钮执行下列
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
//获取将要保存的文件名,并将其中的文件获取并保存
richTextBox1.SaveFile(saveFileDialog.FileName, RichTextBoxStreamType.PlainText);
//保存后清空内容 ,相当于新建文件
richTextBox1.Clear();
}
else
return; //不保存,返回文件编辑界面
}
break; //switch,case的结构是每一个case都要有break
case DialogResult.No: //选择不保存文件
richTextBox1.Clear(); //清空内容 ,相当于新建文件
break;
case DialogResult.Cancel: //选择取消,
break; //不对文件内容做更改,直接返回
}
}
else
richTextBox1.Clear(); //文件内容未作更改,直接清空文件内容
}
//打开文件的方法
private void OpenFile()
{
//判断文件是否修改过 包括空格
if (txtchange)
{
//实例化对话框的成员re为对话框的按钮Yes,No,Cancle
DialogResult re;
re = MessageBox.Show("内容已更改,是否保存?", "保存提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
//判断所选按钮
switch (re)
{
case DialogResult.Yes: //选择保存
{
//如果保存对话框选择保存执行以下
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
//获取将要保存的文件名,并将其中的文件获取并保存
richTextBox1.SaveFile(saveFileDialog.FileName, RichTextBoxStreamType.PlainText);
//保存完毕,调用打开文件方法
OpenFile_2();
}
}
break; //返回新打开的文件
case DialogResult.No: //选择不保存,直接弹出打开文件对话框
{
OpenFile_2();
}
break; //返回新打开的文件
case DialogResult.Cancel: //选择取消按钮,返回至编辑界面
break;
}
}
else
{
OpenFile_2(); //文件内容没有更改,直接弹出打开文件对话框
}
}
//保存和另存的方法
private void SaveFile()
{
//当用户单击保存时save = true
if (save == true)
{
//选择保存对话框按钮 OK
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
//获取将要保存的文件名,并将其中的文件获取并保存
richTextBox1.SaveFile(saveFileDialog.FileName, RichTextBoxStreamType.PlainText);
}
else
return; //返回至编辑界面
}
else //此为用户选择另存为按钮时save = false
{
//选择另存对话框按钮 OK
if (saveAsFileDialog.ShowDialog() == DialogResult.OK)
{
//获取将要保存的文件名,并将其中的文件获取并保存
richTextBox1.SaveFile(saveAsFileDialog.FileName, RichTextBoxStreamType.PlainText);
}
else
return; //返回至编辑界面
}
}
private void OpenFile_2()
{
//弹出打开文件对话框
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
//将Form1的Text属性赋值为文件名
Text = openFileDialog.FileName;
//获取文件内容,加载数据流至richTextBox.Text
richTextBox1.LoadFile(openFileDialog.FileName, RichTextBoxStreamType.PlainText);
}
}
#endregion
#region 其他事件
//鼠标位置
private void richTextBox1_MouseMove_1(object sender, MouseEventArgs e)
{
//将鼠标的坐标显示在任务栏的toolLabel_Mouse的属性Text中
toolLabel_Mouse.Text = e.X.ToString() + "." + e.Y.ToString();
}
//显示系统时间
private void timer1_Tick(object sender, EventArgs e)
{
//将系统时间赋给任务栏的toolLabel_Time的属性Text中
toolLabel_Time.Text = DateTime.Now.ToString();
}
//打开时的时间
private void Form1_Load(object sender, EventArgs e)
{
//将加载窗体时的时间赋给toolLabel_Opentime.Text
toolLabel_Opentime.Text = DateTime.Now.ToString("MM-dd H:mm:ss"); //MM-dd H:mm:ss 其中得一个H表示上午时显示一位数,例如8点,而不是显示08
}
#endregion
#region richtextbox 右键菜单
//*****************右键菜单实现的功能与编辑菜单中相应的编辑键有相同的功能***********//
private void 撤销ToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Undo();
}
private void 复制ToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Copy();
}
private void 剪切ToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Cut();
}
private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Paste();
}
private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.SelectedText = "";
}
#endregion
#region 菜单 右键菜单
//当鼠标再菜单和任务栏右击时的菜单
private void 关于记事本ToolStripMenuItem_Click(object sender, EventArgs e)
{
About ab = new About();
ab.label5.Text = "制作:/n/n汪祖华-李涛-孙远飞-闫兴/n/n技术支持:鄢涛老师";
ab.Show();
}
#endregion
}
}
- <font size="4" color="#ff0000"><strong><u>Class1.cs </u></strong></font><strong><u><font size="4" color="#ff0000">************************************************</font></u></strong>
Class1.cs ************************************************
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Windows.Forms;
-
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
//using System.IO;
- namespace txttest
- {
- class Class1
- {
namespace txttest
{
class Class1
{
- public void About_1()
- {
- System.Diagnostics.Process.Start("<a href="http:
- }
- public void About_2()
- {
- System.Diagnostics.Process.Start("<a href="http:
- }
- public void About_3()
- {
- System.Diagnostics.Process.Start("<a href="http:
- }
- }
- }
public void About_1()
{
System.Diagnostics.Process.Start("http://www.cdu.edu.cn/");
}
public void About_2()
{
System.Diagnostics.Process.Start("http://computer.cdu.edu.cn/");
}
public void About_3()
{
System.Diagnostics.Process.Start("http://computer.cdu.edu.cn/teacher/teacherIndex.action?id=4af3db8e1902c49a01190362138f003b");
}
}
}
- <font size="4" color="#ff0000"><strong><u>Class2.cs </u></strong></font><strong><u><font size="4" color="#ff0000">*************************************************</font></u></strong>
Class2.cs *************************************************
- using System;
- using System.Collections.Generic;
- using System.Text;
using System;
using System.Collections.Generic;
using System.Text;
- namespace txttest
- {
- class Class2 : Class1
- {
-
- }
- }
namespace txttest
{
class Class2 : Class1
{
//继承于:Class1
}
}
- <font size="4" color="#ff0000"><strong><u>About.cs **************************************************</u></strong></font>
About.cs **************************************************
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
- namespace txttest
- {
- public partial class About : Form
- {
- public About()
- {
- InitializeComponent();
- }
-
-
-
-
- Class2 sp = new Class2();
- private void timer1_Tick(object sender, EventArgs e)
- {
- label4.Text = DateTime.Now.ToLongDateString() + "/n" + DateTime.Now.ToLongTimeString();
namespace txttest
{
public partial class About : Form
{
public About()
{
InitializeComponent();
}
/******************************************************************/
/******************************************************************/
/******************************************************************/
/******************************************************************/
Class2 sp = new Class2();
private void timer1_Tick(object sender, EventArgs e)
{
label4.Text = DateTime.Now.ToLongDateString() + "/n" + DateTime.Now.ToLongTimeString();
}
- private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- sp.About_1();
- }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
sp.About_1();
}
- private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- sp.About_2();
- }
private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
sp.About_2();
}
- private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- sp.About_3();
- }
- }
- }