List (Of Graphicspath)

sankalpsonik

New member
Joined
Oct 12, 2017
Messages
3
Programming Experience
Beginner
I have created some graphic objects as graphicspath. I have placed two command button on form. On clicking button1 it should call graphicspath and draw the graphic objects when a mouse is clicked on the form(drawing space). On clicking button2 it would call different graphicspath. I am trying to store all this in List of so that previously placed graphicspath are also shown.

However, on clicking command button it shows the graphicspath and on mouse click it places on the form. But is not saving. As soon as I click on Command Button2 the earlier placed graphicspath (placed thru command button 1 disappears)

Please suggest

Attached is the code
 

Attachments

  • graphicspath problem.txt
    3 KB · Views: 56
There's no such thing as a "Command Button". It's just a Button.

It's rarely a good thing to attach a text file to your post. If you have relevant code to post, post it directly, within appropriate formatting tags.

I'm guessing the issue here is that your drawing code is not in the correct place. Firstly, never call CreateGraphics. The only place to perform GDI+ drawing on a form or control is in the Paint event handler of that form or control. If you're not doing that then that's why you're having issues. Move all your drawing code to the appropriate Paint event handler and use the Graphics object provided. Whenever you want to change the drawing, change the appropriate data and then call the Invalidate method of the form or the control you want to draw on. The Paint event will then be raised, which will automatically erase to the existing drawing and add the new. Note that, while you can call Invalidate with no arguments, it's generally preferred that you specify the smallest area that you reasonable can so that only parts of the form or control that have or may have changed will be repainted. The repainting part, not the drawing part, is quite slow so the less of that that gets done the better.

If you follow this advice and still have issues, please post the relevant code and only the relevant code as requested.
 
Thanks for your reply. Please bear with me as I have just started programming. Can I request you to change the code accordingly in the text file so that I can learn from it

Appreciate your help
 
Nope. Post the relevant code directly and I'll point out where it has issues and I may post corrections specifically if I consider it warranted. I'm not a big fan of just writing peoples code for them because, while examples and the like are important, the best way to learn is to do. It's often harder, but it's more rewarding in the end.
 
Back
Top