C# 刷新picturebox
我在picturebox上通过鼠标拖拉画出了图像,在此以鼠标画直线为例,但是直线并不能适时的显示出来,但是如果将窗口最小化,然后打开,这样直线才能显示出来,所以我想是不是需要刷新的问题,如果不是的话,请高手指点,注:指点希望详细点,我是菜鸟
2011-10-30 21:45
PictureBox pb = new PictureBox();
pb.Invalidate();这是手动刷新的代码 如果是想自动刷新的话 就把绘制的代码写在 pb的paint事件里
2011-10-30 22:16
2011-10-31 10:09
2011-10-31 10:39
2011-10-31 10:42
2011-10-31 11:46
2011-10-31 21:16
程序代码: private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
Pen p = new Pen(Color.Crimson);
using (Graphics g = pictureBox1.CreateGraphics())
{
pictureBox1.Refresh();//刷新图像显示,作用是清除上次画的内容
g.DrawLine(p, new Point(e.X, 0), new Point(e.X, pictureBox1.Height));
g.DrawLine(p, new Point(0, e.Y), new Point(pictureBox1.Width, e.Y));
g.DrawString(string.Format("{0}, {1}", e.X, e.Y),
new Font("", 10), new SolidBrush(Color.Red), new Point(e.X + 10, e.Y - 10));
}
}随鼠标移动,在PictureBox中画两根交差的线和坐标
2011-11-01 09:13
2011-11-05 04:30