By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,152 Members | 2,159 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,152 IT Pros & Developers. It's quick & easy.

User Control with transparent background

P: n/a
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.SupportsTransparentBac kColor, 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
*-----------------------*
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
See the Windows Forms Tips and Tricks section on transparent controls.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Efkas" <fl**@rfranco-dot-ca.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
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.SupportsTransparentBac kColor, 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
*-----------------------*

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.