Amazon Contextual Product Ads

Thursday, February 10, 2011

Set Font Attributes RichTextBox Control

بسم الله الر حمن الر حيم

          You can set Font in richTextBox control just in one line code, do not believe? I will showing to you:

          Before you set font in richTextBox, you can set font in Properties Toolbar, in Font. You can find fonts installed on your computer here and set the font without code. But it’s was not effective, because you can only set one time only. iwill showing to you, how to set font in richtextBox with code:

richTextBox1.SelectionFont = new Font("Tahoma", 12, FontStyle.Bold);


richTextBox1.SelectionFont = new Font("Arial", 10, FontStyle.Bold);


richTextBox1.SelectionFont = new Font("Times New Roman", 20, FontStyle.Bold);

Or, you can set font on richTextBox from fontDialog:




richTextBox1.Font = fontDialog1.Font;

For full view:



private void button1_Click(object sender, System.EventArgs e)
{
   if(fontDialog1.ShowDialog() == DialogResult.OK)
   {
      richTextBox1.Font = fontDialog1.Font;
   }
}

If font not installed on your computer, font automatically set to default font on your PC.


Alhamdulillah, Hopefully helpful,,,

No comments:

Post a Comment