Color effects - background picture streching

otherside

Well-known member
Joined
Mar 16, 2003
Messages
127
Location
UK - Greece
Hello guys
anyone know how can i set the background color to a control like labels to have some effect like fading on the one side ?

and another question

how can i set the background picture to strech and not repeat ?
 
Theres no built in way to have the gradient on the back of the label, but you can easily paint the control yourself. Heres an example:
Code:
Private Sub Label1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Label1.Paint
        Dim g As Graphics = e.Graphics
        Dim gradBrush As New Drawing2D.LinearGradientBrush( _
            New Point(0, Label1.Height / 2), _
            New Point(Label1.Width, Label1.Height / 2), _
            Color.PowderBlue, _
            Color.Green)

        g.FillRectangle(gradBrush, Label1.ClientRectangle)
        g.DrawString(Label1.Text, Label1.Font, _
            New Pen(Label1.ForeColor).Brush, 1, 1)
        gradBrush.Dispose()
End Sub
As for stretching the fonts image, youll need to do something similar to the label. You just get the Forms paint event and use the DrawImage method of the forms graphics object to draw the image over the entire window (DrawImage will scale it for you).
 
On second thought, that DrawString line should be this:
Code:
g.DrawString(Label1.Text, Label1.Font, _
            New Pen(Label1.ForeColor).Brush, New RectangleF(1, 1, Label1.Width, Label1.Height))
otherwise you wont get text wrapping.
 
Back
Top