本文介绍了图形绘画OnPaint()方法的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么此代码与Button_Click(在表单上)正确执行,
但是当它与Form_load一起执行时却没有响应???

why this code with Button_Click(On Form) excecute correctly,
But when it with Form_load Excecuted it not response???

private void button1_Click(object sender, EventArgs e)
       {
           String drawString = "Sample Text";

           // Create font and brush.
           Font drawFont = new Font("Arial", 16);
           SolidBrush drawBrush = new SolidBrush(Color.Black);

           // Create point for upper-left corner of drawing.
           Point drawPoint = new Point(20, 20);

           // Draw string to screen.
           Graphics p= pictureBox1.CreateGraphics();

           Graphics k = this.CreateGraphics();
           p.DrawString(drawString, drawFont, drawBrush, drawPoint);


       }



-------------------------------------------------- ----------------------



------------------------------------------------------------------------

private Form_Load(object sender, EventArgs e)       //not response
       {
           String drawString = "Sample Text";

           // Create font and brush.
           Font drawFont = new Font("Arial", 16);
           SolidBrush drawBrush = new SolidBrush(Color.Black);

           // Create point for upper-left corner of drawing.
           Point drawPoint = new Point(20, 20);

           // Draw string to screen.
           Graphics p= pictureBox1.CreateGraphics();

           Graphics k = this.CreateGraphics();
           p.DrawString(drawString, drawFont, drawBrush, drawPoint);


       }

推荐答案




这篇关于图形绘画OnPaint()方法的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 13:44
查看更多