码迷,mamicode.com
首页 > Windows程序 > 详细

C# winform 编写记事本

时间:2018-03-18 23:23:14      阅读:440      评论:0      收藏:0      [点我收藏+]

标签:tool   filter   led   obj   nta   post   pos   result   event   

 

技术分享图片技术分享图片

 

 

//用colorDialog窗口控件设置字体颜色
private void toolStripButton1_Click(object sender, EventArgs e)
{
DialogResult drt = colorDialog1.ShowDialog();
if (drt == DialogResult.OK)
{
richTextBox1.ForeColor = colorDialog1.Color;
}
}
//读取文件路径
private void toolStripButton5_Click(object sender, EventArgs e)
{
DialogResult drt = folderBrowserDialog1.ShowDialog();
if (drt==DialogResult.OK)
{
MessageBox.Show(folderBrowserDialog1.SelectedPath);

}


}
//用fontDialog窗体控件设置字体样式
private void toolStripButton2_Click(object sender, EventArgs e)
{
DialogResult drt = fontDialog1.ShowDialog();
if (drt==DialogResult.OK)
{
richTextBox1.Font = fontDialog1.Font;
}
}
//用openFileDialog控件打开文件
private void toolStripButton3_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "文本文档(*.txt)|*.txt|所有文件(*.*)|*.*";
DialogResult drt = openFileDialog1.ShowDialog();
if (drt==DialogResult.OK)
{
richTextBox1.LoadFile(openFileDialog1.FileName,RichTextBoxStreamType.PlainText);
}
}
//打开文本文件中的超链接
private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(e.LinkText);
}
//用saveFileDialog控件保存文件
private void toolStripButton4_Click(object sender, EventArgs e)
{
saveFileDialog1.Filter = "文本文档(*.txt)|*.txt";
DialogResult drt = saveFileDialog1.ShowDialog();
if (drt==DialogResult.OK)
{
MessageBox.Show(saveFileDialog1.FileName);
richTextBox1.SaveFile(saveFileDialog1.FileName,RichTextBoxStreamType.PlainText);
}
}

C# winform 编写记事本

标签:tool   filter   led   obj   nta   post   pos   result   event   

原文地址:https://www.cnblogs.com/jasonch123/p/8598032.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!