how to keep the drawing on picturebox when new drawing is added?VB.Net
-
i have form1 and form2, form1 has a picturebox which i already drew something on it(e.g. rectangle) i active form2 to chose another shape to add below the rect, after form2 closed, the new shape should be added below the rect and the rect should be remained in its original position on the picbox(something like drawing flowchart).i used picbox_Paint event handler to draw the rect, but when i added new shape using the same Paint handler the rect is gone??!is there anyway to fix this problem?? what i try to find is the way to keep the drawing on the picbox remained till the application is closed... below is my current coding summary
private sub picbox_paint(e....) .... handles paint
if drawmode = 1 then
e.graphic.drawrect()
'this is the first drawingpicbox.invalide()
'refresh picboxend if
if drawmode = 2 then
'this means user chose another shape from form2e.graphic.drawXX()
'this is second drawingpicbox.invalide()
'refresh picboxend if
end sub
-
i have form1 and form2, form1 has a picturebox which i already drew something on it(e.g. rectangle) i active form2 to chose another shape to add below the rect, after form2 closed, the new shape should be added below the rect and the rect should be remained in its original position on the picbox(something like drawing flowchart).i used picbox_Paint event handler to draw the rect, but when i added new shape using the same Paint handler the rect is gone??!is there anyway to fix this problem?? what i try to find is the way to keep the drawing on the picbox remained till the application is closed... below is my current coding summary
private sub picbox_paint(e....) .... handles paint
if drawmode = 1 then
e.graphic.drawrect()
'this is the first drawingpicbox.invalide()
'refresh picboxend if
if drawmode = 2 then
'this means user chose another shape from form2e.graphic.drawXX()
'this is second drawingpicbox.invalide()
'refresh picboxend if
end sub
You have to rewrite your paint handler to paint BOTH rectangles. WHat your doing in your handler is telling the PicBox to invalidate it's entire client area. THen your handling the paint event yourself, but never redrawing the first rectangle. You have to modify your code to keep track of EVERYTHING that you want repainted in the picbox, then redraw it all yourself since your handling the paint event yourself. RageInTheMachine9532
-
i have form1 and form2, form1 has a picturebox which i already drew something on it(e.g. rectangle) i active form2 to chose another shape to add below the rect, after form2 closed, the new shape should be added below the rect and the rect should be remained in its original position on the picbox(something like drawing flowchart).i used picbox_Paint event handler to draw the rect, but when i added new shape using the same Paint handler the rect is gone??!is there anyway to fix this problem?? what i try to find is the way to keep the drawing on the picbox remained till the application is closed... below is my current coding summary
private sub picbox_paint(e....) .... handles paint
if drawmode = 1 then
e.graphic.drawrect()
'this is the first drawingpicbox.invalide()
'refresh picboxend if
if drawmode = 2 then
'this means user chose another shape from form2e.graphic.drawXX()
'this is second drawingpicbox.invalide()
'refresh picboxend if
end sub
:rose::rose: Guess RageInTheMachine9532 is saying this so u retain both images: private sub picbox_paint(e....) .... handles paint if drawmode = 1 then e.graphic.drawrect() 'this is the first drawing picbox.invalide() 'refresh picbox end if if drawmode = 2 then 'this means user chose another shape from form2 e.graphic.drawrect() 'this is the first drawing e.graphic.drawXX() 'this is second drawing picbox.invalide() 'refresh picbox end if end sub
-
:rose::rose: Guess RageInTheMachine9532 is saying this so u retain both images: private sub picbox_paint(e....) .... handles paint if drawmode = 1 then e.graphic.drawrect() 'this is the first drawing picbox.invalide() 'refresh picbox end if if drawmode = 2 then 'this means user chose another shape from form2 e.graphic.drawrect() 'this is the first drawing e.graphic.drawXX() 'this is second drawing picbox.invalide() 'refresh picbox end if end sub
thanks for RageInTheMachine9532 and kamush help!! but wat i actually drawing is a flowchart, which mean each time user define a new drawmode or shape, the coding is very long and complicated and the label of the drawing will be different...if i change the code to wat u suggested me, my coding will be tremedous long and complicated!! i dunno whether u understand me or not(my english is pretty poor)... anyway thanks for ur help...i post a new question about this problem, if u have new idea plz reply there ok? thanks very much!!