C#中的绘图问题 [英] Drawing problem in C#

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

问题描述

你好!
我正在使用Visual C#2008
我正在编写Windows窗体应用程序.
在MainForm中,我有一个名为myPanel的面板和一个名为myButton的按钮. 当用户按下按钮时,面板上应出现一行.
我可以在MainForm中画一条线,但在面板中不能.
我认为我们应该创建面板的图形对象.
我该怎么办?

Hello!
I''m working with Visual C# 2008
I''m coding a windows form application.
In MainForm I have a panel named myPanel and a button named myButton.
When the user presses on the button a line should be appear in the panel.
I can draw a line in MainForm but in the panel I can''t.
I think we should create a graphic object of panel.
How can I do it?
Thanks in advance!

推荐答案

不要创建图形上下文,请处理面板绘画事件.
事件处理程序包含一个PaintEventArgs参数,该参数具有适合您绘制的Graphics对象.
Don''t create a graphics context, handle the panel paint event instead.
The event handler contains a PaintEventArgs argument which has a suitable Graphics object for you to draw on.


这篇关于C#中的绘图问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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