将图形封装在类中 [英] Encapsulate Graphing in a Class

查看:62
本文介绍了将图形封装在类中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将所有与绘图有关的例程放在与Form1类分开的类中.该图形将绘制在表单上的面板上.我有一个尝试执行我想要的操作的测试代码,但是paint事件处理程序无法正常工作.有人解决方案吗?

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?

推荐答案

将其放入UserControl:这样便可以绘制自身.处理它的Paint事件,然后将MyGraphControl添加到窗体中-一切正常.
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.


请查看我过去的解决方案:
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


这篇关于将图形封装在类中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆