How do I change the Font Size on the tabs?

7 posts, 0 answers
  1. Terry Delongchamp
    Terry Delongchamp avatar
    3 posts
    Member since:
    Nov 2009

    Posted 27 Sep 2011 Link to this post

    I did some searching around, but couldn't find an answer to this.

    I have a PageView with 2 tabs that I have set to use the Office2007Silver theme.  I have added images to both of the tab and while those look nice the text on the tabs is too small and I would like to increase it.

    I have tried changing the font size in several places, but none of them change the font.

    I tried directly in the properties of the PageView object. 

    I also expanded the PageView Tasks and clicked "Edit UI Elements" because this section helped me change properties of buttons I'd applied a theme to.  I tried the PageViewLabelElements, StripButtonElements... eventually I changed the font size for every single element in this section, but nothing changed.

    So where/how do I change the font size on a tab on a PageView object that has a theme applied to it?

    /<evin

  2. Terry Delongchamp
    Terry Delongchamp avatar
    3 posts
    Member since:
    Nov 2009

    Posted 28 Sep 2011 Link to this post

    The solution on this page:
    http://www.telerik.com/community/forums/winforms/page-view/want-the-page-name-to-be-in-black-color.aspx

    is close.  I can use it to change the color of the text on the tabs, but unfortunately "page.item.font.size" is a read-only property.

    Is there really no way to change the font size in the designer?

    /<evin




  3. Ivan Petrov
    Admin
    Ivan Petrov avatar
    682 posts
    Member since:
    Sep 2012

    Posted 30 Sep 2011 Link to this post

    Hi Terry,

    Thank you for writing.

    If you do not have a theme applied, you can change the font size by directly changing the Font property of the RadGridView. In your case, with a theme applied, you have to directly change the font of the tab items. Consider the following code snippet which achieves this:

    Font newfont = new Font(this.radPageView1.Font.FontFamily, 20);
    RadPageViewStripElement stripElement = (RadPageViewStripElement)this.radPageView1.ViewElement;
     
    foreach (RadPageViewStripItem item in stripElement.ItemContainer.ItemLayout.Children)
    {
      item.Font = newfont;
    }

    I hope this will help. if you have further questions, I would be glad to help.

    Regards,
    Ivan Petrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  4. Terry Delongchamp
    Terry Delongchamp avatar
    3 posts
    Member since:
    Nov 2009

    Posted 30 Sep 2011 Link to this post

    That did the trick, thanks.  I will add a new section to my page load event to go through and change all of the tabs.

    I have the same issue with the RadGridView column headers.  How can I edit the font there for a grid that has a style applied to it?

    /<evin

  5. Ivan Petrov
    Admin
    Ivan Petrov avatar
    682 posts
    Member since:
    Sep 2012

    Posted 04 Oct 2011 Link to this post

    Hello Terry,

    Thank you for your reply.

    You can use the RadGridView ViewCellFormatting event to change the font of the grid header cells. Here is a code snippet which demonstrates this:

    public Form1()
    {
      this.radGridView1.ViewCellFormatting += new CellFormattingEventHandler(radGridView1_ViewCellFormatting);
    }
     
    void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
      if (e.CellElement is GridHeaderCellElement)
      {
        e.CellElement.Font = new Font(e.CellElement.Font.FontFamily, 20);
      }
    }

    Should you have further questions do not hesitate to ask. Greetings,
    Ivan Petrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Kevin
    Kevin avatar
    30 posts
    Member since:
    Sep 2012

    Posted 04 Oct 2011 Link to this post

    How would that be written in VB? 

    When I try the if statement below it tells me "GridHeaderCellElement is a type and cannot be used as an expression".

    /<evin

  7. Kevin
    Kevin avatar
    30 posts
    Member since:
    Sep 2012

    Posted 04 Oct 2011 Link to this post

    OK, I figured it out... should have just given it an extra half hour. =)

    The VB version of the IF statement would be:
       

    If TypeOf(e.CellElement) Is GridHeaderCellElement Then
        e.CellElement.Font = New Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point)
    End If

    Thank you for your help.

    /<evin

     

Back to Top