Click here to Skip to main content
15,898,010 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wish to put all routines having to do with graphing in a class separate from the Form1 class. The graph is to be drawn on a panel located on the form. I have a test code that tries to do what I want but the paint event handler does not work right. Does anybody have a solution?
Posted

Make it into a UserControl: that way it can draw itself. Handle it's Paint event, and add a MyGraphControl to your form - it should all work fine.
 
Share this answer
 
Comments
Bob Magatagan 2-Jul-11 10:34am    
I thought about that but that makes it complex for the users to handle. I have a test program I wanted to attach to my question but I couldn't figure how to attach it. It shows what I have in mind.
Thanks for your quick response. I really appreciate it,
Bob
OriginalGriff 2-Jul-11 10:40am    
Not really: a UserControl is just a class, but one you can add to the display programatically or via the Toolbox is VS.
Whatever you were going to do in a class, you can do in the control, but with the advantage that it draws itself (and thus encapsulates functionality better).
Bob Magatagan 6-Jul-11 18:08pm    
But can you really draw the graphic on a panel in the form1 class that is not included in the user control. In my case, the graphic is a bitmap image. Sorry waited so long to respond; pressing engagtements, Bob
Please see my past solution: How do I clear a panel from old drawing[^].

Please ask me your follow-up questions. The problem is pretty simple.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900