我的程序很简单,就是启动一个Timer,然后DrawLine重复画一条连续的折线。因为效率的问题,我的程序不要求在窗口被覆盖时重绘,由此不要onPaint里重绘,但现在的问题是我的窗口在绘图时,当鼠标操作其他程序时,测试程序有时也会刷新,即使测试程序的窗口并没有被覆盖或者被影响。网上有这样说,去掉Onpaint,但是也没有用:
protected override void OnPaint(PaintEventArgs e)
{
// base.OnPaint(e);
}
protected override void OnPaintBackground(PaintEventArgs e)
{
// base.OnPaintBackground(e);
}请问怎么办?
protected override void OnPaint(PaintEventArgs e)
{
// base.OnPaint(e);
}
protected override void OnPaintBackground(PaintEventArgs e)
{
// base.OnPaintBackground(e);
}请问怎么办?
解决方案 »
- 求助:Windows 2008 IIS 7 发布网站图片不显示
- winform mdi子窗体 禁用还原按钮
- 請問各位大蝦!誰知道哪裡有c#控件的講座,包涵實例的!謝謝!
- Java提供的.jar文件在c#.net下面可以调用吗?
- C#进度条问题
- The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF
- 求一个C#能执行脚本类的
- 判断输入的是否字符(A-Z,a-z),数字,其他字符,还有汉字的一种方法
- 我在本机上用C#写完了的一个winform项目,现在想让其他电脑访问我的这个项目,应该怎么搭建C/S结构?
- 新画的 panel+pictureBox挡住了原来的图形,如何让他们到底层去?
- DataGrid数据绑定的问题
- 字符串截取问题(求正则表达式)
这个思路是对的,创建一个 Image 对象
Image img = new Bitmap(500, 500);
this.BackgroundImage = img;
using (Graphics g = Graphics.FromImage(img))
{
g.DrawLine(/*...*/);
g.Save();
}
g.DrawLine(new Pen(Color.Red), new Point(15, 15), new Point(15, 100));//画
t.Tick += delegate
{
if (Form.ActiveForm == this)
{
//update bitmap;
}
};
protected override void OnPaintBackground(PaintEventArgs e)
{
// 注释 base.OnPaintBackground(e);
e.Graphics.DrawRectangle(Pens.Black, 0, 0, 100, 100);
}