• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 573
  • Last Modified:

highlight certain tabs in a windows form tabcontrol

I am coding such that certain controls on a tabcontrol will get their background color set to yellow on form load if the data they contain is newer than when the user last viewed them, but I would also like the tab itself that the control is on to be highlighted. I have hooked the backcolor changed event of the controls, so all I have left to do is the actual hightlighting of the tab, how do I do this?
  • 3
  • 3
  • 2
2 Solutions
Rakesh JaiminiCommented:
use css classes to change background color
check this
Tabs Css classes
.ajax__tab_header: A container element that wraps all of the tabs at the top of the TabContainer. Child CSS classes:.ajax__tab_outer.
.ajax__tab_outer: An outer element of a tab, often used to set the left-side background image of the tab.Child CSS classes: .ajax__tab_inner.
.ajax__tab_inner: An inner element of a tab, often used to set the right-side image of the tab. Child CSS classes:.ajax__tab_tab.
.ajax__tab_tab: An element of the tab that contains the text content. Child CSS classes:none.
.ajax__tab_body: A container element that wraps the area where a TabPanel is displayed. Child CSS classes: none.
.ajax__tab_hover . This is applied to a tab when the mouse is hovering over. Child CSS classes:.ajax__tab_outer.
.ajax__tab_active: This is applied to a tab when it is the currently selected tab. Child CSS classes:.ajax__tab_outer.
you can use .ajax__tab_body

Bob LearnedCommented:
CSS doesn't apply to the Windows Forms TabControl.  What do you mean by "highlighting"?
bmutchAuthor Commented:
I somehow want to "highlight" the text on the tab "header" to indicate that a control on the tab is "old"...
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Bob LearnedCommented:
The cool and tricky thing about the TabControl is that you can set DrawMode = OwnerDrawFixed, and then handle the TabControl.DrawItem event.  This changes the appearance of the TabControl, though, and is usually not desirable.

Rakesh JaiminiCommented:

oops i missed windows form :D
here goes the solution for windows forms
above link contains

Can anyone kindly help me in changing the background colour of the TabControl panel. The important parts of my code are:

this.tabControl1.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.tabControl1_DrawItem);

private void tabControl1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
Graphics g = e.Graphics;
Brush b = Brushes.Yellow;
g.FillRectangle(b, tabControl1.DisplayRectangle);

Note: The DrawItem event is never called. Why? Bug or Me? Any workarround?

Looking forward to some wisdom.

Thanking you in advance

also check following links for more customizations
bmutchAuthor Commented:
how do I get the above to occur AFTER a control on the tabpage is populated, ie. how can I force the DrawItem event to occur?

Bob LearnedCommented:
The DrawItem event happens whenever the control is painted.  If you need to force a paint, then you can use the Invalidate method.
bmutchAuthor Commented:
thanks guys, have it working now.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now