using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Drawing1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/*protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
Pen p=new Pen(Color.Black,2);
g.DrawRectangle(p, 10, 10, 150, 100);
Pen creed = new Pen(Color.Red, 2);
g.DrawRectangle(creed, 60, 60, 2, 2);
this.DoubleBuffered = true;
}*/
private void Form1_Paint(object sender,PaintEventArgs e)
{
Graphics g = e.Graphics;
Pen p = new Pen(Color.Black, 2);
g.DrawRectangle(p, 10, 10, 150, 100);
Pen creed = new Pen(Color.Red, 2);
g.DrawRectangle(creed, 60, 60, 2, 2);
this.DoubleBuffered = true;
}
}
}
这段代码用注释中的部分可以运行,但用下面这段时没有编译错误,窗体却没有任何反应,求解~~~~
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Drawing1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/*protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
Pen p=new Pen(Color.Black,2);
g.DrawRectangle(p, 10, 10, 150, 100);
Pen creed = new Pen(Color.Red, 2);
g.DrawRectangle(creed, 60, 60, 2, 2);
this.DoubleBuffered = true;
}*/
private void Form1_Paint(object sender,PaintEventArgs e)
{
Graphics g = e.Graphics;
Pen p = new Pen(Color.Black, 2);
g.DrawRectangle(p, 10, 10, 150, 100);
Pen creed = new Pen(Color.Red, 2);
g.DrawRectangle(creed, 60, 60, 2, 2);
this.DoubleBuffered = true;
}
}
}
这段代码用注释中的部分可以运行,但用下面这段时没有编译错误,窗体却没有任何反应,求解~~~~