C # WinForm Writing Notepad

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.