Alistair Evans
Alistair Evans

Reputation: 36473

Semi-transparent panel background

I have a panel which sits on top of a control that renders video. I have controls (buttons, etc), on that panel which I want to be fully opaque. Now, creating a transparent panel background is doable, by overriding the CreateParams property. However, how to I make a panel with a semi-transparent (~50% opacity) background, while keeping the buttons fully opaque?

I am using .NET 2.0.

Upvotes: 1

Views: 2672

Answers (2)

Alistair Evans
Alistair Evans

Reputation: 36473

In the end it turned out that this isn't possible really, setting transparency on a panel is pretty rubbish in WinForms.

The workaround I used was to render the controls manually onto the given surface, and alter the alpha values appropriately.

Upvotes: 2

Jason Musgrove
Jason Musgrove

Reputation: 3583

You could use two panels, one placed within the other. The outer panel has no background, and hosts the inner panel and the controls, and the inner panel, whose Z-Index places it behind the controls, provides the semi-transparent background.

I'll admit that I'm suggesting this without actually verifying that this will work...

Upvotes: 1

Related Questions