Need transparent label but with a slight difference

A

Adam Maltby

Hi,

I need to do a transparent label but with a difference.

I have drawn on my form a custom background using CreateGraphics as I needed an ellipse looking fill in a rectangle - so the actual background colour of the form is still set to "control" colour.

If I use the background transparent setting instead of seeing my drawn on background and it's gradient i see the forms background colour. If the label was on a solid coloured bit of drawing I would set it to that but since it sits over part of the gradient I need i tto be transparent to show the custom drawing.

Any ideas?

Thanks
Adam
 
M

Mick Doherty

Why have you used createGraphics when you already have a Graphics object(e.Graphics) in the Paint method?
If you use that GraphicsObject, the label will appear Transparent.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html


Hi,

I need to do a transparent label but with a difference.

I have drawn on my form a custom background using CreateGraphics as I needed an ellipse looking fill in a rectangle - so the actual background colour of the form is still set to "control" colour.

If I use the background transparent setting instead of seeing my drawn on background and it's gradient i see the forms background colour. If the label was on a solid coloured bit of drawing I would set it to that but since it sits over part of the gradient I need i tto be transparent to show the custom drawing.

Any ideas?

Thanks
Adam
 
A

Adam Maltby

Hi,

But it going transparent all the way to the form background - i need it to transparent to the gradient I drew on the form.

Cheers
Adam
 
M

Mick Doherty

If you draw the form background in the forms Paint method using the Graphics object e.Graphics, then the transparent label will paint itself with the Gradient that you drew on the form.
If you Draw the forms background outside of the paint method using CreateGraphics, then the transparent label will paint itself with the forms backcolor.

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

Dim FillBrush As New Drawing2D.LinearGradientBrush(ClientRectangle, _
Color.Blue, Color.Red, _
Drawing2D.LinearGradientMode.ForwardDiagonal)
e.Graphics.FillRectangle(FillBrush, ClientRectangle)
FillBrush.Dispose()
End Sub
///

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html


Hi,

But it going transparent all the way to the form background - i need it to transparent to the gradient I drew on the form.

Cheers
Adam
 
A

Adam Maltby

Excellent! Thanks a lot.
Still getting to grips with the overall options of graphics painting in vbnet (as you no doubt gathered) - that was a big help!

Thanks
Adam
 

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