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

Controlling tab Colors

3 Answers 103 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.
bobebs
Top achievements
Rank 1
bobebs asked on 06 Jun 2007, 07:30 PM
How do I programmically change the color of a tab(s) on the tabstrip depending certain conditions.  I tried changing both the foregcolor and backcolor properties but it does not work.  Do I have to change the "theme"?  if so how?

3 Answers, 1 is accepted

Sort by
0
Boyko Markov
Telerik team
answered on 08 Jun 2007, 03:56 PM
Hello Bob,

You could use the ClassSelector class to select the fill of the TabItem and then modify the BackColor 
properties of that TabItem. The following code demonstrates how to change the backColor of an instance of TabItem.
   
    ClassSelector fillSelector = new ClassSelector("TabFill");
    FillPrimitive tabFill = fillSelector.GetSelectedElements(this.tabItem2)[0] as FillPrimitive;
    tabFill.BackColor = Color.Red;
    tabFill.BackColor2 = Color.Red;
    tabFill.BackColor3 = Color.Red;
    tabFill.BackColor4 = Color.Red;

The next block demonstrates how to reset the values of the BackColor properties.

     ClassSelector fillSelector = new ClassSelector("TabFill");
     FillPrimitive tabFill = fillSelector.GetSelectedElements(this.tabItem2)[0] as FillPrimitive;
      tabFill.ResetValue(FillPrimitive.BackColorProperty);
      tabFill.ResetValue(FillPrimitive.BackColor2Property);
      tabFill.ResetValue(FillPrimitive.BackColor3Property);
      tabFill.ResetValue(FillPrimitive.BackColor4Property);


I hope this helps.


Kind regards,
Ray
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
BillFugina
Top achievements
Rank 1
answered on 16 Dec 2008, 02:48 AM
How would I do the same thing for the various states of the tabs?
0
Boyko Markov
Telerik team
answered on 18 Dec 2008, 03:47 PM
Hello BillFugina,

I think the only possible approach here is to handle the Mouse events of the control and apply different colors in the different states. However the best approach is to build your own custom theme using our tool for building themes - VisualStyleBuilder. You can find more information about it here:
http://www.telerik.com/help/winforms/themes_overview.html


Greetings,
Boyko Markov
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
bobebs
Top achievements
Rank 1
Answers by
Boyko Markov
Telerik team
BillFugina
Top achievements
Rank 1
Share this question
or