paint graphics on panel with menuitem1.click

PG74

New member
Joined
Aug 4, 2004
Messages
2
I want to paint some lines and fonts on a panel, but I want it to paint when I click on a menuitem, have tried the code below, but it paints when I open the form. I dont want it to paint untill I call the sub with my MenuItem3.click.

Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
here is the code for lines and fonts
end sub

Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
Panel1_Paint() calling the sub to paint the panel
End Sub

have heard you can use a sub "panel1.refresh()" or something like that, but I dont know how it works.
someone have an example code or can explain for me?? please!

thanks!
 
Dim ClickedMenuItem as Boolean


Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
ClickedMenuItem = True
End Sub

Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
If ClickedMenuItem Then
Code
End If
end sub
 
you can draw directly from inside your menuClick event

do like this

dim g as Graphics
g = me.CreateGraphics();

g.Drawstring("test",font,x,y);

..........

g.Dispose();


hope it helps
 
Back
Top