C# winform 編寫記事本

來源:互聯網
上載者:User

標籤: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 編寫記事本

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.