I feel a bit like a mountain climber everytime I try and do something with the .NET tab control. I just know there is going to be some new obstacles to overcome. Today I noticed on this thread at vbCity an interesting question, How do I make it when I select a tab, the other one Dims, or looks inactive. and so decided to try and answer it.
The first major problem was that the tab control simply doesn't support any sort of altering of the tab text directly. When you disable the tab all the controls on the tab become disabled, not the tab itself. This lead onto the two issues I needed to overcome, namelyI had no idea how to control the drawing of the tab text.I've never actually found out what is involved in making a control look disabled.
Never one to let small problems like that put me off I returned to a site that djjeavons had pointed out to me in this post, Re: How do I disable or make a tab control tab invisible.The web site is Mick Dohertys DotNet Tips - TabControl. Mick has some excellent code examples for how to extend the tab control's functionality.
Mick had some code that showed how to change the colours of the tab text and background and so after a few minutes spent trawling the internet to find out what colours I should be using to make a control look disabled I was able to perform a small tweak to Mick's code and get the non-selected tabs to look disabled.
For the record it appears that for a disabled control the background colour should remain the same but the text colour should change to System.Drawing.SystemColors.GrayText. I posted the code and hope it provides the solution extatic was looking for. I'll add this functionality to my tab control extension class.