C#程序写字板.docx

上传人:b****7 文档编号:23439507 上传时间:2023-05-17 格式:DOCX 页数:17 大小:18.69KB
下载 相关 举报
C#程序写字板.docx_第1页
第1页 / 共17页
C#程序写字板.docx_第2页
第2页 / 共17页
C#程序写字板.docx_第3页
第3页 / 共17页
C#程序写字板.docx_第4页
第4页 / 共17页
C#程序写字板.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

C#程序写字板.docx

《C#程序写字板.docx》由会员分享,可在线阅读,更多相关《C#程序写字板.docx(17页珍藏版)》请在冰豆网上搜索。

C#程序写字板.docx

C#程序写字板

(注:

那个常用工具栏里的字体、字号、字符集不能用)

主窗体里全部代码:

usingSystem;

using;

using;

using;

using;

using;

using;

using;

namespaceNOTEBOOK

{

publicpartialclassForm1:

Form

{

Findfind=newFind();

replacereplace=newreplace();

publicForm1()

{

InitializeComponent();

=this;

=this;

for(inti=0;i<=-1;i++)

{

}

}

privatevoidForm1_Load(objectsender,EventArgse)

{

ilter="文本文件(*.txt)|*.txt|RTF文档|*.rtf|所有文件|*.*";

if(打开.ShowDialog()==

{

stringfn=打开.FileName;

stringext=(fn);xt")

{

(@fn,;

}

elseif()==".rtf")

{

(@fn,;

}

else

{

("系统不支持该类型文件!

","写字板");

}

}

}

privatevoid保存SToolStripMenuItem_Click(objectsender,EventArgse)

{

SaveFileDialogsaveFileDialog1=newSaveFileDialog();

if==true)

{

="保存";

="*.txt";xt|所有文档|*.*";

if()==

{

stringfn=;

(fn,;

=false;

=+"-写字板";

}

}

else

{

;

=false;

}

}

privatevoid另存为ToolStripMenuItem_Click(objectsender,EventArgse)

{

SaveFileDialogsaveFileDialog1=newSaveFileDialog();

="另存为";

="*.txt";

="文本文档(*.txt)|*.txt|所有文档|*.*";

if()==

{

StreamWritersw=newStreamWriter;

(richTextBox1);

=false;

stringfn=;

();

=+"-写字板";

}

}

privatevoid打印PToolStripMenuItem_Click(objectsender,EventArgse)

{

if<1)

{

("请确保要查找的文件的内容不为空!

","提示");

return;

}

else

{

PrintDialogprint=newPrintDialog();

DialogResultresult=();

}

}

privatevoid退出XToolStripMenuItem_Click(objectsender,EventArgse)

{

if!

="")

{

保存SToolStripMenuItem_Click(sender,e);

}

else

{

();

}

}

etDataPresent)

{

this.粘贴=true;

}

else

{

this.粘贴=false;

}

isible=false;

}

else

{

工具栏=true;

工具栏.Visible=true;

}

}

privatevoid格式栏FToolStripMenuItem_Click(objectsender,EventArgse)

{

if(格式栏

{

格式栏=false;

格式栏.Visible=false;

}

else

{

格式栏=true;

格式栏.Visible=true;

}

}

privatevoid状态栏SToolStripMenuItem_Click(objectsender,EventArgse)

{

if(状态栏

{

状态栏=false;

状态栏.Visible=false;

}

else

{

状态栏=true;

状态栏.Visible=true;

}

}

ont=;

字体.Color=;

if(字体.ShowDialog()==

{

if>0)

{

=字体.Font;

=字体.Color;

}

else

{

=字体.Font;

=字体.Color;

}

}

}

privatevoid颜色CToolStripMenuItem_Click(objectsender,EventArgse)

{

颜色.Color=;

if(颜色.ShowDialog()==

{

if>0)

{

=颜色.Color;

}

else

{

=颜色.Color;

}

}

}

etDataPresent)

{

this.剪切=true;

}

else

{

this.剪切=false;

}

//根据选择区域不为空,则复制、剪切、删除可用,否则不可用

if>0)

{

复制=true;

剪切=true;

删除=true;

}

else

{

复制=false;

剪切=false;

删除=false;

}

//如果写字板内容不为空,则全选可用,否则不可用

if>0)

{

全选=true;

}

else

{

全选=false;

}

}

///

///窗体关闭按钮

///

///

///

privatevoidForm1_FormClosing(objectsender,FormClosingEventArgse)

{

if==true)

{

DialogResultr;

r=("您是不要将更改保存到文档吗","写字板",,;

if(r==

{

保存SToolStripMenuItem_Click(sender,e);

if==true)

{

=true;

}

else

{

=false;

}

}

elseif(r==

{

=true;

}

elseif(r==

{

=false;

}

}

else

{

=false;

}

}

///

///在状态栏显示鼠标位置

///

///

///

privatevoidrichTextBox1_MouseMove(objectsender,MouseEventArgse)

{

="所在位置:

"++","+;

}

}

}

(注:

区分大小写、方向用不了)

查找窗体代码:

usingSystem;

using;

using;

using;

using;

using;

usingNOTEBOOK

{

publicpartialclassFind:

Form

{

intp=0;

publicFind()

{

InitializeComponent();

}

privatevoidtextBox1_TextChanged(objectsender,EventArgse)

{

if=="")

{

=false;

}

else

{

=true;

}

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

Form1fmain=(Form1);

p=if(p!

=-1)

{

p++;

}

else

{

("已查找到文档尾!

","写字板",,;

p=0;

}

}

privatevoidFind_FormClosing(objectsender,FormClosingEventArgse)

{

=true;

();

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

();

}

}

}

 

(注:

那个区分大小写用不了)

查找窗体代码:

usingSystem;

using;

using;

using;

using;

using;

usingNOTEBOOK

{

publicpartialclassreplace:

Form

{

intp=0;

boolthflag=false;

publicreplace()

{

InitializeComponent();

}

privatevoidtextBox1_TextChanged(objectsender,EventArgse)

{

Form1fmain=(Form1);

=0;

=0;

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

//查找下一个(未完善)

Form1fmain=(Form1);

p=p);

if(p!

=-1)

{

p++;

}

else

{

("已查找到文档尾!

","写字板",,;

p=0;

}

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

//替换

Form1fmain=(Form1);

p=p);

if(p!

=-1)

{

=;

p++;

}

else

{

("已替换完!

“"++"”!

","写字板",,;

p=0;

}

}

privatevoidbutton3_Click(objectsender,EventArgse)

{

//全部替换

Form1fmain=(Form1);

intl=+if(l!

=-1)

{

=;

thflag=true;

}

else

{

if(thflag==true)

{

("替换完毕!

");

}

else

{

("替换内容不存在,请重新输入!

");

}

}

}

privatevoidreplace_FormClosing(objectsender,FormClosingEventArgse)

{

=true;

();

}

}

}

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 其它

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1