c# 重绘窗体 的 OnPaint事件

来源:百度知道 编辑:UC知道 时间:2024/06/04 18:32:40
public partial class Form1 : Form
{
Bitmap topLeft;
public Form1()
{
InitializeComponent();
topLeft = new Bitmap(@"I:\新建文件夹\1.bmp");
}
public void Pa(Graphics g)
{
g.DrawImage(topLeft, 90, 0, topLeft.Width, topLeft.Height);
}
protected override void OnPaint(PaintEventArgs e)
{
}
OnPaint 事件里怎么写啊?郁闷死了。。

你想要在OnPaint里写什么啊?
protected override void OnPaint(PaintEventArgs e)
{
Pa(e.Graphics);
}
这就画你那图

推荐您去这看看,这样的问题都有详细的解决方法,他们的.net教程讲解的比较全,你可以去学习下,希望对你有帮助
参考资料:http://www.baidu.com/s?wd=%B1%B1%B7%E7%CD%F8&rsv_bp=0&rsv_spt=3&inputT=422

onpaint事件是系统程序在加载的时候自动调用的,所以你只要是在程序中的代码写正确了之后,就不用再管其他的了...

base.OnPaint(e);
Graphics dc = e.Graphics;
//下面用dc做你想做的

效率很不好.因为onpaint事件会被触发n多次....