highlight certain tabs in a windows form tabcontrol

Posted on 2010-01-08
Last Modified: 2013-12-17
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?
Question by:bmutch
    LVL 10

    Expert Comment

    by:Rakesh Jaimini
    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

    LVL 96

    Expert Comment

    by:Bob Learned
    CSS doesn't apply to the Windows Forms TabControl.  What do you mean by "highlighting"?

    Author Comment

    I somehow want to "highlight" the text on the tab "header" to indicate that a control on the tab is "old"...
    LVL 96

    Accepted Solution

    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.

    LVL 10

    Assisted Solution

    by:Rakesh Jaimini

    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

    Author Comment

    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?

    LVL 96

    Expert Comment

    by:Bob Learned
    The DrawItem event happens whenever the control is painted.  If you need to force a paint, then you can use the Invalidate method.

    Author Closing Comment

    thanks guys, have it working now.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now