Making a control with transparent background

  • Thread starter Thread starter Juan Romero
  • Start date Start date
J

Juan Romero

Hey guys,
Does anyoone know how to make a control with transparent background?

This is what I have so far and it doesn't work:

Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True)
Me.UpdateStyles()
Me.BackColor = Color.Transparent
Invalidate()

This allows me to set the background color to transparent, but when I run
the form, the control still draws with color.

Any other ideas?

Thanks!
 
Juan,

* "Juan Romero said:
Does anyoone know how to make a control with transparent background?

This is what I have so far and it doesn't work:

Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True)
Me.UpdateStyles()
Me.BackColor = Color.Transparent
Invalidate()

Maybe this post will help you to understand what
'SupportsTransparentBackColor' actually does:

<URL:http://www.google.de/groups?selm=1kKZXIwhBHA.2504@cpmsftngxa07>
 
Thanks for replying Herfried,

I checked out the link you gave me, but that still does not answer my
question.

I knew this is not really the way, I actually posted the style thing
with my message so someone else wouldn't come and give me the same
answer >:)

Any other ideas?

Thanks!

Regards,
Juan Romero
(To e-mail me remove the underscores from my e-mail address.)
 
* Juan Romero said:
I checked out the link you gave me, but that still does not answer my
question.

I knew this is not really the way, I actually posted the style thing
with my message so someone else wouldn't come and give me the same
answer >:)

If the shape is not too complex, create a 'GraphicsPath' of appropriate
form, convert it to a 'Region' and assign this region to the controls
(hidden) 'Region' property.
 
I am completely new to imaging (as you can already see) which is why I
am playing with these things, hoping to learn. Can you please give me
some sample code or links I can follow to better understand this?

Thanks!

Regards,
Juan Romero
(To e-mail me remove the underscores from my e-mail address.)
 
* Juan Romero said:
I am completely new to imaging (as you can already see) which is why I
am playing with these things, hoping to learn. Can you please give me
some sample code or links I can follow to better understand this?

For example, add this code to the usercontrol's 'Load' event handler:

\\\
Dim intDiameter As Integer = 300
Me.Height = intDiameter
Me.Width = intDiameter
Dim p As New Drawing2D.GraphicsPath()
p.AddEllipse(0, 0, intDiameter, intDiameter)
Me.Region = New Region(p)
p.Dispose()
Me.BackColor = Color.Red
///
 
Back
Top