This is a migrated thread and some comments may be shown as answers.

Change tab color and restore to original color

1 Answer 149 Views
Tabstrip (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
joseph_korn
Top achievements
Rank 1
joseph_korn asked on 21 Aug 2008, 08:41 PM
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.

1 Answer, 1 is accepted

Sort by
0
Accepted
Nikolay
Telerik team
answered on 22 Aug 2008, 10:33 AM
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.
Tags
Tabstrip (obsolete as of Q2 2010)
Asked by
joseph_korn
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or