Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Tabstrip (obsolete as of Q2 2010) > Change tab color and restore to original color

Answered Change tab color and restore to original color

Feed from this thread
  • joseph_korn avatar

    Posted on Aug 21, 2008 (permalink)

    As per the instructions given in this thread: http://www.telerik.com/community/forums/thread/b311D-mkmhd.aspx 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) 
     
            oTabFill.ResetValue(FillPrimitive.BackColorProperty) 
            oTabFill.ResetValue(FillPrimitive.BackColor2Property) 
            oTabFill.ResetValue(FillPrimitive.BackColor3Property) 
            oTabFill.ResetValue(FillPrimitive.BackColor4Property) 
    Next 

    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.

    Reply

  • Answer Nikolay Nikolay admin's avatar

    Posted on Aug 22, 2008 (permalink)

    Hi joseph_korn,

    Thank you for this question.

    After you reset the values of all the BackColor properties, you should call the ForceApplyTheme() method:
    Me.tsTabs.RootElement.ForceApplyTheme(); 

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

    All the best,
    Nikolay
    the Telerik team

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

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Tabstrip (obsolete as of Q2 2010) > Change tab color and restore to original color
Related resources for "Change tab color and restore to original color"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]