transparent controls

D

Derrick

Is it possible to make the background color of controls (such as group
boxes, lables, text boxes and check boxes, tabpage ) to transparent?

In case you need more information, I have added some code to the form_paint
method to paint the background with a gradiant. I need to get the controls
on the form to match the same look. The only alternative I could come up
with was to create an image with the color gradiant, and setting that to the
background of the form and controls - which really seems to be a silly
approach.

Thanks for any help.

Derrick
 
E

Eric Eggermann

Derrick said:
Is it possible to make the background color of controls (such as group
boxes, lables, text boxes and check boxes, tabpage ) to transparent?

In case you need more information, I have added some code to the form_paint
method to paint the background with a gradiant. I need to get the controls
on the form to match the same look. The only alternative I could come up
with was to create an image with the color gradiant, and setting that to the
background of the form and controls - which really seems to be a silly
approach.

Thanks for any help.

Derrick

Did you try setting the backcolor to transparent on the controls? That
should do what you want. Click the controls backcolor in the property
window. It's towards the top of the Web tab in the color editor that pops
up.

HTH
Eric
 
D

Derrick

Yep - the transparent Back color doesn't work with any controls that I have
seen. Using that setting makes all controls have the 'control' color
background in run time.

Derrick
 
D

David Clegg

Derrick said:
Yep - the transparent Back color doesn't work with any controls that
I have seen. Using that setting makes all controls have the
'control' color background in run time.

Could you post your form_paint code? I had a similar problem due to a
silly oversight on my part. Instead of using the Graphics object passed
in the PaintEventArgs, I was creating my own. End result; controls
didn't have transparent backgrounds.

--
Cheers,
David Clegg
dclegg_at_ebetonline_dot_com

"Vampires are make believe, just like elves and gremlins and
eskimos." - Homer Simpson
 
D

Derrick

Here it is...

Private Sub frmMain_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim objBrush As New
Drawing2D.LinearGradientBrush(Me.DisplayRectangle, Color.White,
Color.CornflowerBlue, Drawing2D.LinearGradientMode.Vertical)
Dim objGraphics As Graphics = Me.CreateGraphics()
objGraphics.FillRectangle(objBrush, Me.DisplayRectangle)
objBrush.Dispose()
objGraphics.Dispose()
End Sub

Thanks

Derrick
 
D

Derrick

And, thanks to David's great insight, I did find the problem... I modified
the paint method to:

Private Sub Form_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

Dim objBrush As New Drawing2D.LinearGradientBrush(Me.DisplayRectangle,
Color.White, Color.CornflowerBlue, Drawing2D.LinearGradientMode.Vertical)
e.Graphics.FillRectangle(objBrush, Me.DisplayRectangle)
objBrush.Dispose()

End Sub
Thanks for the help

Derrick
 
D

David Clegg

Herfried said:
Nice X-Face.

<g>

Didn't help much during the RWC though. Oh well, at least LOTR cleaned
up the Oscars :)

--
Cheers,
David Clegg
dclegg_at_ebetonline_dot_com

"Hello? Operator! Give me the number for 911!" - Homer Simpson
 

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