我在鼠标单击事件中添加了添加控件和绘图代码,可是新绘制的图形和控件却被其他控件盖住,不能显示,请问诸位大侠如何解决?
代码:
单击事件:
Label label_cap = new Label
label_cap.Location = new Point(1, 1);
label_cap.Size = new Size(202, 202);
label_cap.BackColor = Color.Green;
label_cap.AutoSize = false;
label_cap.Visible = true;
label_cap.FlatStyle = FlatStyle.Standard ;
label_cap.SendToBack();
this.Controls.Add(label_cap); 绘图事件:
private void draw_pic()
{
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(0, 0, 200, 300));
myBrush.Dispose();
formGraphics.Dispose();
}在paint事件中
代码:
单击事件:
Label label_cap = new Label
label_cap.Location = new Point(1, 1);
label_cap.Size = new Size(202, 202);
label_cap.BackColor = Color.Green;
label_cap.AutoSize = false;
label_cap.Visible = true;
label_cap.FlatStyle = FlatStyle.Standard ;
label_cap.SendToBack();
this.Controls.Add(label_cap); 绘图事件:
private void draw_pic()
{
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(0, 0, 200, 300));
myBrush.Dispose();
formGraphics.Dispose();
}在paint事件中
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货