Petr
Petr

Reputation: 14505

how to create transparent label in toolbox in winforms

I have a System.Windows.Forms.ToolStrip which contains a Label.

The ToolStrip has a special fancy background. But the label is just gray. Toolbar

It's not possible to use transparency because the parent of ToolStrip is a form. Also it's not possible to change the parent, because the collection of Controls in ToolStrip is read only.

Is it possible to create a Label that is transparent and which has a ToolStrip parent?

Upvotes: 0

Views: 1046

Answers (2)

RogerN
RogerN

Reputation: 3821

If you just delete the assigned background color of the ToolStripLabel then it ought to inherit the background of its parent ToolStrip. I use a custom ToolStripRenderer to draw a customized background for tool strips, and my labels do not need any special handling in order to inherit the parent's background. Just make sure you aren't trying to assign a background color.

Upvotes: 1

will simmons
will simmons

Reputation: 187

Give the following a shot.

Set the backcolor of the label to Color.Transparent. Then you have to add the label directly to the control collection of the control of which you want the label to appear transparent on top of.

Upvotes: 1

Related Questions