views:

821

answers:

2

Hello,

I would like to put a LinkLabel with a transparent background over a TabControl. The tab control has NO tabpage.

As it's not possible to add controls other than TabPages to a TabControl, what I do it add the LinkLabel to the control that contains the TabCOntrol, and then use BringToFront on the LinkLabel. This displays it over the TabControl.

Problem: The LinkLabel displays as transparent (BackColor Property), but instead of showing the TabControl's colour as background, it shows the background colour of it's parent, the control that also contains the TabControl. From what I understand, this is normal behaviour as a Transparent BackColor means that it'll just take the parent's colour.

Question: Is there any solution to display my LinkLabel with the TabControl's background colour?

Thanks

+1  A: 

I may be wrong about this, but I think that if you change the LinkLabel's BackColor property in code (e.g. in your form's Load event, as opposed to just setting it in the designer) to match the color of your TabControl, it will work the way you want it to.

MusiGenesis
Thanks for your answer but it's already what I'm doing (setting it from the code) and it does not work :(Apparently, BackColor = Transparent means that it'll take the parent's background colour.
David
Yes, setting BackColor to Transparent, actually means, use the parent's BackColor. I think what Music was trying to say was set the BackColor (in code, at run-time) to tabcontrol.BackColor.
NascarEd
What Ed said. :)
MusiGenesis
instead of settingit to transparent (if that doesnt work like you said) then choose the color name of the parent. i.e. if the tabcontrol is white, change the backcolor of your label to white.
baeltazor
A: 

Hello,

Thanks for your answers. I'm now get what you meant.

Using the tab Control's BackColor won't work, because this property always returns the ColorSystemColors.Control, which is greyish. However, when using visual styles (e.g. XP's default theme), the TabControl's back colour is kind of white. I cannot use white either as the tab control is not pure white, but gradient white...

Look through all the available system colors and you'll probably find the one you need.
MusiGenesis
From my understanding, it's not a system colour but it's defined in uxtheme.dll.Maybe a solution would be to use native methods from that dll to draw my label's background... too much bother.I ended up using a transparent Label I found there, and modified it to look like a LinkLabel.http://www.codeproject.com/KB/miscctrl/SimpleLine.aspx Thanks for your help anyway :)
David