Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 571
  • 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"...
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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.

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

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