How do I get this code to work from from the getgo? It works If I put it in the mouse events but not the controls paint event. I have tried adapting different methods from several threads but I cannot seem to get any of them to work.....
VB Code:
Private Sub DrawGradientButton(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Button1.Paint Try Dim g As Graphics = Button1.CreateGraphics Dim rect As New Rectangle(0, 0, Button1.Width, Button1.Height) Dim br As New System.Drawing.Drawing2D.LinearGradientBrush(rect, Color.White, Color.SlateGray, Drawing2D.LinearGradientMode.Horizontal) Dim x As Single = CSng(Button1.Width / 2) Dim y As Single = CSng(Button1.Height / 4) Dim sBrush As New System.Drawing.SolidBrush(Color.WhiteSmoke) Dim Font As System.Drawing.Font = Button1.Font Dim txt As String = Button1.Text g.FillRectangle(br, rect) g.DrawString(txt, Font, sBrush, x, y) br.Dispose() g.Dispose() Catch ex As Exception MsgBox(ex.Message) End Try End Sub
Thank you!!
D




Reply With Quote