Transparency

M

Marco Trapanese

Hi!

I need to create a user control with transparent background. Picturebox
for example doesn't show any other control under it even if it has the
background color set to transparent.

Which control should I use?

Thanks
Marco / iw2nzm
 
A

Andrew Christiansen

You can set the SupportsTransparentBackgroundColor bit in the constructor of
your user control using MyBase.SetStyle. This will allow you to set the
control's BackColor property to a color with an alpha value other than 255.

- Andrew
 
M

Marco Trapanese

Andrew said:
You can set the SupportsTransparentBackgroundColor bit in the
constructor of your user control using MyBase.SetStyle. This will allow
you to set the control's BackColor property to a color with an alpha
value other than 255.


Thanks for your answer. I already did it. But it doesn't works.
The background will be transparent to the form but not to other controls
behind it.

Example:

Place a button in the middle of the form. Place a picture box over it
and set the background color of the picture box as transparent. It
doesn't show the button.

This is what I want! :)

Bye
Marco / iw2nzm
 
R

rowe_newsgroups

Thanks for your answer. I already did it. But it doesn't works.
The background will be transparent to the form but not to other controls
behind it.

Example:

Place a button in the middle of the form. Place a picture box over it
and set the background color of the picture box as transparent. It
doesn't show the button.

This is what I want! :)

Bye
Marco / iw2nzm

AFAIK, there is not a way to do this with a control. What exact are
you trying to accomplish - perhaps we know of a better way? Also, GDI+
supports alpha drawing, so you might look into using it to drawing
directly onto the form instead of just placing a control.

Thanks,

Seth Rowe
 
M

Marco Trapanese

rowe_newsgroups said:
AFAIK, there is not a way to do this with a control.

urgh :(
What exact are
you trying to accomplish - perhaps we know of a better way? Also, GDI+
supports alpha drawing, so you might look into using it to drawing
directly onto the form instead of just placing a control.

Ok! I use GDI+ but I'd like to do something like this (I hope I can
explain it with my poor English!)

I created a progress bar with an 'angle' property which draws the bar in
any direction. However, the container of the control is a box. I need to
put several progress bars over each other. I might draw each bar
directly on the form but it would be nice if I can use them separately
as user control.

The transparency is required because the unused space around the bar
must shows other controls behind it.
 
C

Chris Dunaway

urgh :(


Ok! I use GDI+ but I'd like to do something like this (I hope I can
explain it with my poor English!)

I created a progress bar with an 'angle' property which draws the bar in
any direction. However, the container of the control is a box. I need to
put several progress bars over each other. I might draw each bar
directly on the form but it would be nice if I can use them separately
as user control.

The transparency is required because the unused space around the bar
must shows other controls behind it.

Instead of using a box as the container of your control, set the
controls Region property to the exact shape that you need.

Have you considered using WPF? With WPF its almost trivial to display
any control at an angle.

Chris
 

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