C# winform 初始化图像问题
我想在调用一个页面的时候初始化显示图像。代码如下Graphicsgx=null;Bitmapimg=null;privatevoidForm2_Load(objectse...
我想在调用一个页面的时候初始化显示图像。
代码如下
Graphics gx=null;
Bitmap img=null;
private void Form2_Load(object sender, EventArgs e)
{
img = Properties.Resources.Loading;
this.gx = this.CreateGraphics();
gx.DrawImage(img, 0, 0);
Pen pen = new Pen(Color.Red, 2);
gx.DrawLine(pen, 100, 100, 200, 200);
}
调试时没反应,但是我把该代码放到button click事件里却有作用 private void button1_Click_1(object sender, EventArgs e)
{
img = Properties.Resources.Loading;
this.gx = this.CreateGraphics();
gx.DrawImage(img, 0, 0);
Pen pen = new Pen(Color.Red, 2);
gx.DrawLine(pen, 100, 100, 200, 200);
}
不知道为什么,请强人解决下! 展开
代码如下
Graphics gx=null;
Bitmap img=null;
private void Form2_Load(object sender, EventArgs e)
{
img = Properties.Resources.Loading;
this.gx = this.CreateGraphics();
gx.DrawImage(img, 0, 0);
Pen pen = new Pen(Color.Red, 2);
gx.DrawLine(pen, 100, 100, 200, 200);
}
调试时没反应,但是我把该代码放到button click事件里却有作用 private void button1_Click_1(object sender, EventArgs e)
{
img = Properties.Resources.Loading;
this.gx = this.CreateGraphics();
gx.DrawImage(img, 0, 0);
Pen pen = new Pen(Color.Red, 2);
gx.DrawLine(pen, 100, 100, 200, 200);
}
不知道为什么,请强人解决下! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询