To set the font color with the ColorDialog window control
private void Toolstripbutton1_click (object sender, EventArgs e)
{
DialogResult DRT = Colordialog1.showdialog ();
if (DRT = = DialogResult.OK)
{
Richtextbox1.forecolor = colorDialog1.Color;
}
}
Read file path
private void Toolstripbutton5_click (object sender, EventArgs e)
{
DialogResult DRT = Folderbrowserdialog1.showdialog ();
if (Drt==dialogresult.ok)
{
MessageBox.Show (Folderbrowserdialog1.selectedpath);
}
}
To set a font style with the FontDialog form control
private void Toolstripbutton2_click (object sender, EventArgs e)
{
DialogResult DRT = Fontdialog1.showdialog ();
if (Drt==dialogresult.ok)
{
Richtextbox1.font = Fontdialog1.font;
}
}
To open a file with the OpenFileDialog control
private void Toolstripbutton3_click (object sender, EventArgs e)
{
Openfiledialog1.filter = "Text document (*.txt) |*.txt| All Files (*. *) |*.*";
DialogResult DRT = Openfiledialog1.showdialog ();
if (Drt==dialogresult.ok)
{
Richtextbox1.loadfile (Openfiledialog1.filename,richtextboxstreamtype.plaintext);
}
}
Open a hyperlink in a text file
private void Richtextbox1_linkclicked (object sender, Linkclickedeventargs e)
{
System.Diagnostics.Process.Start (E.linktext);
}
Save a file with the SaveFileDialog control
private void Toolstripbutton4_click (object sender, EventArgs e)
{
Savefiledialog1.filter = "Text document (*.txt) |*.txt";
DialogResult DRT = Savefiledialog1.showdialog ();
if (Drt==dialogresult.ok)
{
MessageBox.Show (Savefiledialog1.filename);
Richtextbox1.savefile (Savefiledialog1.filename,richtextboxstreamtype.plaintext);
}
}
C # WinForm Writing Notepad