Font change in textbox

3 posts, 0 answers
  1. ankit
    ankit avatar
    5 posts
    Member since:
    Oct 2007

    Posted 24 Mar 2011 Link to this post


    In my project i need to change  font size and font family at runtime through code. Can anyone please tell me how can i do it?

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Mar 2011 Link to this post


    You can change the ForeColor of RadTextBox control by changing the ForeColor  of its subelements RadTextBoxItem and FillPrimitive:

    radTextBox1.TextBoxElement.TextBoxItem.ForeColor = Color.Red;         
    ((FillPrimitive)this.radTextBox1.TextBoxElement.Children[1]).ForeColor = Color.Red;

    And here is the form, which discusses similar scenario:

  3. DevCraft R3 2016 release webinar banner
  4. Ivan Petrov
    Ivan Petrov avatar
    701 posts

    Posted 25 Mar 2011 Link to this post

    Hello ankit,

    Thank you for writing.

    You can change the font by assigning a Font variable to the Font property of RadTextBox. Consider the following code snippet:

    public partial class Form1 : Form
       Font font;
       public Form1()
          this.font = new Font("Arial", 14, FontStyle.Bold | FontStyle.Italic);
          this.radTextBox1.Font = this.font;

    Note that it is a good idea to have fonts created only once in your app, because the creation of a font is a heavy operation and can lead to memory leaks.

    I hope this will help. If you have further questions, I would be happy to help.


    Best wishes,
    Ivan Petrov
    the Telerik team
Back to Top