System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
System.Drawing.Graphics formGraphics = this.panelEx1.CreateGraphics();
formGraphics.FillRectangle(myBrush, new System.Drawing.Rectangle(20, 5, 50, 80));
为什么不显示
System.Drawing.Graphics formGraphics = this.panelEx1.CreateGraphics();
formGraphics.FillRectangle(myBrush, new System.Drawing.Rectangle(20, 5, 50, 80));
为什么不显示
是panel控件吗?
我用panel控件+你的代码是可以画出一个红色的矩形啊
我估计你用的一个扩展的自定义控件,该控件不允许自绘
{
e.Graphics.DrawRectangle(Pens.Blue, start.X, start.Y, end.X - start.X, end.Y -start.Y);
}
private void picBox_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
draw = true;
start = e.Location;
}
}
private void picBox_MouseMove(object sender, MouseEventArgs e)
{
this.Cursor = Cursors.Default;
end = e.Location;
picBox.Invalidate();
}
private void picBox_MouseUp(object sender, MouseEventArgs e)
{
picBox.DrawToBitmap(bit, picBox.ClientRectangle);
picBox.Image = bit;
draw = false;
}
这是在图片上画的应该差不多