//获得选项卡里的控件,r为RichTextBox,l1为路径栏,l2为保存提示栏
if (l2 != null && (l2.Text == "未保存" || l2.Text == "新建"))
{ 保存SToolStripMenuItem_Click(sender, e); }
}//end for
this.Close();
}//end result.ToString() == "Yes"
else if (result.ToString() == "No")
{ this.Close(); }// end result.ToString() == "No"
else { } //取消动作
}//end if (v > 0)
else { this.Close(); }//如果没有未保存的文本则直接关闭不需要提醒用户
}
第十是:获得选项卡里的控件,r为RichTextBox,l1为路径栏,l2为保存提示栏,这样就差不多解决了整个程序了,因为程序的基本框架已经呈现了:
RichTextBox r = null;
Label l1 = null, l2 = null;
foreach (Control c in tabControl1.SelectedTab.Controls)
{
if (c is RichTextBox)
{
r = (RichTextBox)c;
}
if (c is Label)
{
if (l1 == null) l1 = (Label)c;
else if (l2 == null) l2 = (Label)c;
}
}
第十一是:获得绝对路径下的文件名,save.FileName是绝对路径 :
tabControl1.SelectedTab.Text = System.IO.Path.GetFileName(save.FileName);
第十二是:当按钮可用时要设置为 true 属性:(否则设为 flase )
另存为AToolStripMenuItem.Enabled = true;
剪切TToolStripMenuItem.Enabled = true; 复制CToolStripMenuItem.Enabled = true;
删除ToolStripMenuItem.Enabled = true; 查找FToolStripMenuItem.Enabled = true;
替换ToolStripMenuItem.Enabled = true; 转到ToolStripMenuItem.Enabled = true;
全选ToolStripMenuItem.Enabled = true; 时间与日期ToolStripMenuItem.Enabled = true;
字体ToolStripMenuItem.Enabled = true; 段落ToolStripMenuItem.Enabled = true;
主题HToolStripMenuItem.Enabled = true; 颜色AToolStripMenuItem.Enabled = true;
toolStripButton4.Enabled = true; toolStripButton5.Enabled = true; toolStripButton7.Enabled = true;
toolStripButton8.Enabled = true; toolStripButton9.Enabled = true; toolStripButton10.Enabled = true; 第十三是:变量的说明:(定义了几个全局变量下面分别说明)
int NF = 1,m=0,v=0;// NF是记数新建文件的次数,只加不减,m 是选项卡个数,动态变化
// v 是需要进行保存的选项卡个数,也是动态变化的一个值
private MessageBoxButtons button;//退出时提示对话框的按钮风格
private MessageBoxIcon icon; //退出时提示对话框的图标风格
搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新资格考试认证C多文本编辑器考试报告(7)全文阅读和word下载服务。
相关推荐: