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