如何在keydown事件里面调用paint事件
或者,在paint的事件里面使用keydown的判断,如何用,求高手!
[解决办法]
KeyDown += (ss, ee) =>
{
if (ee.KeyCode == Keys.C)
{
MessageBox.Show(ee.KeyValue + "");
}
};
public void refreshImg(Image image)
{
Bitmap bufferBmp = (Bitmap)image;//new Bitmap(200, 200); //创建位图缓冲区
Graphics g = this.panel1.CreateGraphics(); //创建窗体图形
Pen pen = new Pen(Color.Red);
Graphics buf_g = Graphics.FromImage(bufferBmp);
buf_g.Dispose(); //绘画已完成,释放掉buf_g
g.DrawImage(bufferBmp, 0, 0); //将bufferBmp中的内容画到屏幕上
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.A)
{
Image img = null;
refreshImg(img);
}
}