Transparent LinkLabel over TabControl - c#

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

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.

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...

Related

Customizing appearance of Form and Controls

I have set the BackColor property of the form and all controls within it to white, but still some of it has the Control (gray) color (e.g. the context menu of the MenuStrip, the tabs of the TabControl, and the border of the form itself).
Basically I'm trying to make the appearance of my application in flat white.
Is it possible to achieve this in WinForms?

Making a transparent tab background?

I was wondering if I could draw the background of a tabpage in C# transparent like so I can see behind the window itself. I though it would give a cool effect but I don't know if or how I can do it.
You can set the Appearance property of TabControl to Buttons Instead of using BackColor property. That would bring transparent tab page look and cool effect.
VB & C# syntax
TabPage1.BackColor = Color.Transparent
this will show the tabpage1 color as the form color.

transparent tab control appears white

Anyway, I'm having a little difficulty with tab control. When I drag a new tab control onto a form, it appears white, rather than the grey (system colour) I was expecting.
When I look at the properties, its colour is set to web-transparent. Ok, so it should be transparent then (it isn't letting anything behind it show through). Setting the tab control back colour manually back to the system grey kind of works, but the tabs at the top still show as white. I'm assuming I could somehow change their colour as well, but I'm quickly getting into the realms of changing so many values from default, I'm clearly missing something type territory. I've googled every varient of "transparent tab control draws white" as I can, and although I found something to do with windows profiles, this seemed mostly confined to access 2003 using the vb you got access to in access.
I'm looking for any explanation as to:
what I need to do to correctly use transparency with tab controls
what I'm mis-understanding as the purpose of transparency in tab controls
how to easily change all the colours of the appropriate parts of the tab control to not be transparent.
I'm looking at windows forms for an MCTS, so please don't give a "you should use X instead" type answer.
No, getting white is certainly normal. TabControl and TabPage are rendered with theme colors when visual styles are enabled. So that makes the tab page white on machines with the standard Windows theme.
Yes, the default BackColor of Transparent is very unusual. You most certainly will never get actual transparency with that, unless you count seeing the background of the TabControl as transparency. The logic is pretty convoluted, rather than trying to explain it I'll just paste the MSDN explanation:
The default value of the BackColor property is the value of the Control.DefaultBackColor property unless the UseVisualStyleBackColor and Application.RenderWithVisualStyles property values are both true and the Appearance property of the parent TabControl has a value of Normal, in which case the default value of the BackColor property is Transparent. Child controls that you place on the TabPage inherit the BackColor value by default, so this behavior causes the background of the child controls to render with the current visual style.
Changing the value of the BackColor property automatically sets the UseVisualStyleBackColor property to false. If you want the TabPage background to render using visual styles but you want the child controls to inherit a BackColor value that you specify, set the UseVisualStyleBackColor property after you set the BackColor property.

autocompletebox without highlighted border

I have an autocompletebox that I am trying to remove the border from. Just setting the border to a transparent color or a border thickness of zero isn't good enough, because when the box is moused over, a secondary border appears. The style template for the control is cryptic enough for me that my guesses on changing different parameters have not resulted in border changes.
What do I need to do to disable the border for this control?
Normally, this is due to the FocusVisualElement component in styletemplates for controls.
I can see that the Autocompletebox doesn't have this component, but the Autocompletebox itself is built with more basic controls who do have such an element in their style template.
Try making a style for a textbox without the focusvisualelement (remove it completely from the template) and let the textbox inside the Autocompletebox make use of that template, that should remove the border from the autocompletebox.
So the style contained a control template with the textbox used in the autocomplete user control... I just replaced the style specifically for that textbox to show a transparent border on the mouseover state.

ComboBox DropDownStyle DropDownList : Change BackColor WinForms

I am making one app where I highlight currently focused controls.
For TextBox I use the BackColor property.
But in case of a ComboBox with DropDownStyle = DropDownList, BackColor does not seem to make it highlight.
Any suggestion(border etc?) on how can I make the controls Highlight in a consistent manner.
As Reniuz said, you'll need to change the DrawMode properties.
Specifically, changing the DrawMode to OwnerDrawFixed will allow you to specify the BackColor.
System.DrawMode
Normal - All the elements in a control are drawn by the operating system and are of the same size.
OwnerDrawFixed - All the elements in the control are drawn manually and are of the same size.
OwnerDrawVariable - All the elements in the control are drawn manually and can differ in size.
See System.Windows.Forms.DrawMode for more information.
Try to change FlatStyle or DrawMode properties. But control will look a bit different. May be it will fit for you :)

Categories