我有一个带有PictureBox(或面板)的窗体,我想在此PictureBox的点(0,0)处绘制一个矩形。 我该怎么办?
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void DrawIt()
{
System.Drawing.Graphics graphics = this.CreateGraphics();
System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(50, 50, 150, 150);
SolidBrush brush = new SolidBrush(Color.Red);
graphics.DrawRectangle(System.Drawing.Pens.Red, rectangle);
graphics.FillRectangle(brush, rectangle);
}
private void button1_Click(object sender, EventArgs e)
{
this.DrawIt();
}
}`