运行后,Form出不来红色的矩形请问这是啥问题??       
 private void Form1_Load(object sender, EventArgs e)
        {
            Graphics ghs = this.CreateGraphics();//创建Graphics对象
            Brush mybs = new SolidBrush(Color.Red);//使用SolidBrush类创建一个Brush对象
            Rectangle tr = new Rectangle(10, 10, 120, 80); //绘制一个矩形
            ghs.FillRectangle(mybs, tr);//填充矩形
        }

解决方案 »

  1.   

    在Form的OnPaint事件里面绘制,Graphics 直接在事件参数里面
      

  2.   

    知道了form_load事件是无法绑定的
      

  3.   

            private void Form1_Paint(object sender, PaintEventArgs e)
            {
                Graphics ghs = this.CreateGraphics();//创建Graphics对象
                Brush mybs = new SolidBrush(Color.Red);//使用SolidBrush类创建一个Brush对象
                Rectangle tr = new Rectangle(10, 10, 120, 80); //绘制一个矩形
                ghs.FillRectangle(mybs, tr);//填充矩形
            }