line wont draw after button click but draws after tab or alt keypr

G

Guest

Hello,

I have a form with a panel which contains a radiobutton. When I click the
radiobutton, I invoke the Paint event of the panel using me.Invalidate. The
paint event gets called and runs through code to draw a line. But the line
does not draw on the panel until I press either the Alt key or Tab key. Here
is my code:

Sub rad_Click(...)handles...
Me.Invalidate()
End Sub

Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
If rad.Checked.Equals(True) Then
Dim bPen As Pen
bPen = New Drawing.Pen(Color.Blue, 3)
e.Graphics.DrawLine(bPen, 0, 186, 446, 186)
End If
End Sub

How can I make the line draw when I check the radionbutton?

Thanks,
Rich
 
G

Guest

Panel1.Invalidate

I have to invalidate the Panel where I want to draw the line. Now it is
working.
 

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

Similar Threads

Owner Draw Radio Button 2
Help with drawing? 1
Scrolling in a panel 5
Drawing text without labels? 1

Top