Making controls transparent inorder to see a gradient

jray-taf

Member
Joined
Nov 1, 2005
Messages
5
Programming Experience
1-3
Hi,
I put a metallic looking gradient on a form. The problem is that all my controls, lables, groupboxes etc still show as ugly grey squares. I want to make them transparent so the gradient on the form shows through them. I tried
lblMyLabel.BackColor = Color.FromArgb(0, lblMyLabel.BackColor)
and
lblMyLabel.BackColor = Color.FromArg(0,System.Drawing.Color.Transparent).
But with no success.

Can anyone help me make these items completely transparent so the gradient shows through.

Thanks,

Josh
 
Thank you for your reply.

I tried this:
lblMyLabel.Parent = Me
lblMyLabel.BackColor = Color.Transparent

I still could not see the gradient through the label.

I then tried:
lblMyLabel.Parent = Me.Parent

with or without the next line(lblMyLabel.backcolor...) I can see the gradient where the label was but then could not see the text. It looked the the entire label was transparent, including the text.

I seem to be getting somewhere but not quite there yet.

Thank you for your help,
Josh
 
I'm not too sure what MDI form is?? But when lblMyLable.Parent = Me didn't work I just tried messing around.

I am not using a background Image I used the drawing class to make the gradient.

Dim g As Graphics = Me.CreateGraphics

Dim x As Integer = Me.width
Dim y As Integer = Me.Height

Dim lgBrush As New------
g.fillRectangle(lgBrush----)

you get the idea.
I got this code out of a book but it doesn't go any further in depth.
Thanks for your help,
josh
 
I am going to try a different approach

Thank you all for your help. I am still having problems though. I've learned that my controls are transparent if you just set the backcolor to transparent. The problem: they show the forms backcolor and apparently when I draw the gradient on the form it doesn't effect the backcolor so it is what is showing through to the control.
I either need to find a way to paint the gradient as the backcolor or simply just create a gradient as a jpeg,etc in an image editor and use it as the background(this last method does work by the way)
Thanks again for all the input,
josh
 
Code used to paint gradient

Here is the code I use to paint the gradient:

'Private Sub frmMain_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = Me.CreateGraphics
coordinates for both the gradient and the fillRectangle routine:
Dim x As Integer = Me.Width
Dim y As Integer = Me.Height

Dim lgBrush As New LinearGradientBrush(New Point(0, 0), New Point (x,y), Color.White, Color.FromArgb(190, 190, 190))

g.FillRectangle(lgBrush, 0, 0, x, y)

'End Sub

However, I took the easy way out and just created the gradient in an image editor and used it as the backgroud with the controls set to transparent and it works.
I would still like to be able to do it the other way but dont really have a lot of time to waste on this.
Thanks for all your help,
Josh
 
Back
Top