User Control with transparent background

E

Efkas

My application have some level :
1. MyButton class with Label inheritance
2. MyComponent as User Control loading and positionning some of
MyButtons
3. MyApp loading and positionning MyComponent

I prefer don't insert a background in MyComponent, and using the MyApp
one as general background with MyComponent positionned, but I am not
able to have MyComponent background transparent.

I used the following lines to make it transparent :
// Enable the transparent for a control
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);

... this part seems to be OK.
// First test:
// Suppose to be transparent, but display a dark grey as background
// note dark grey is not the default background, the color is changed
to
// dark grey.
this.BackColor = Color.FromArgb(0, 0, 0, 0);

// Second test
// Suppose to be transparent, but same result than first test
this.BackColor = Color.Transparent;

// Third test
// Suppose to be transparent, but not:
// - if (0, Color.Transparent), we obtain a dark grey
// - if (255, Color.Transparent), we obtain a white background
// - if (128, Color.Red), we obtain red transparent and darkgrey
back.
this.BackColor = Color.FromArgb(0, Color.Transparent);

Do you have a suggestion to have my background really transparent and
let see me the background of my main application?

Thanks
François

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top