Change tab color and restore to original color

Thread is closed for posting
2 posts, 1 answers
  1. joseph_korn
    joseph_korn avatar
    21 posts
    Member since:
    Apr 2007

    Posted 21 Aug 2008 Link to this post

    As per the instructions given in this thread: I was able to successfully change the backcolor of a tab programmatically.  When I try to reset the tab color back to its original color, it works fine, except that the color stays changed until I hover over the tab, and then it fully returns to normal.

    For example, I have a tab strip with the default blue colored tabs.  I click a button to change one of the tabs to yellow, and it works.  I click another button to change the color back to the original blue color, but the tab still remains yellow.  When I hover my mouse over the yellow tab, it changes to the hover color, and when I hover away from the tab, it returns to its original blue color.

    Here is a sample of my code used to make the tab turn yellow:

                Dim oFillSelector As New ClassSelector("TabFill") 
                Dim oTabFill As FillPrimitive = TryCast(oFillSelector.GetSelectedElements(Me.tsTabs.SelectedTab)(0), FillPrimitive) 
                If oTabFill.BackColor <> Color.Yellow Then 
                    oTabFill.BackColor = Color.Yellow 
                    oTabFill.BackColor2 = Color.Yellow 
                    oTabFill.BackColor3 = Color.Yellow 
                    oTabFill.BackColor4 = Color.Yellow 
                End If 

    Here is the code I use to return all tabs to their default color:

    For i as int32 = 0 to Me.tsTabs.Items.Count -1 
            Dim oFillSelector As New ClassSelector("TabFill") 
            Dim oTabFill As FillPrimitive = TryCast(oFillSelector.GetSelectedElements(Me.tsTabs.Items(i))(0), FillPrimitive) 

    Please let me know what I am doing wrong, as it is quite annoying to have to hover over all the tabs everytime I want to see which ones are really supposed to have a different backcolor.
  2. Answer
    Nikolay avatar
    1805 posts

    Posted 22 Aug 2008 Link to this post

    Hi joseph_korn,

    Thank you for this question.

    After you reset the values of all the BackColor properties, you should call the ForceApplyTheme() method:

    If you have additional questions, feel free to contact me.

    All the best,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top