
在winform中如何在panel中绘图?
我想在panel中画一个矩形,但没有实现。下面是我在pictureBox1的Paint事件中画的矩形this.pictureBox4.Width=16;this.pict...
我想在panel中画一个矩形,但没有实现。
下面是我在pictureBox1的Paint事件中画的矩形
this.pictureBox4.Width = 16;
this.pictureBox4.Height = 48;
Bitmap bmp = new Bitmap(e.ClipRectangle.Width, e.ClipRectangle.Height);
Graphics dc = Graphics.FromImage(bmp);
dc.FillRectangle(Brushes.Black, 0, 0, 16, 48); //矩形
e.Graphics.DrawImage(bmp, new Point(0, 0));
这个可以画出来
但我改变一下画在panel中就不行了, 这个该怎么解决,如果知道,请给出源码,谢谢了!!!!
还有最好不让图闪烁! 展开
下面是我在pictureBox1的Paint事件中画的矩形
this.pictureBox4.Width = 16;
this.pictureBox4.Height = 48;
Bitmap bmp = new Bitmap(e.ClipRectangle.Width, e.ClipRectangle.Height);
Graphics dc = Graphics.FromImage(bmp);
dc.FillRectangle(Brushes.Black, 0, 0, 16, 48); //矩形
e.Graphics.DrawImage(bmp, new Point(0, 0));
这个可以画出来
但我改变一下画在panel中就不行了, 这个该怎么解决,如果知道,请给出源码,谢谢了!!!!
还有最好不让图闪烁! 展开
展开全部
private void panel1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawRectangle(new Pen(new SolidBrush(Color.Red)), new Rectangle(0, 0, 16, 48));
}
{
Graphics g = e.Graphics;
g.DrawRectangle(new Pen(new SolidBrush(Color.Red)), new Rectangle(0, 0, 16, 48));
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询