动态加入控件的显示问题
为什么以下代码显示不了我要加入的picturebox?
PictureBox pb = new PictureBox();
pb.Location = new System.Drawing.Point(176,72);
pb.Size = new Size(80,13);
pb.BorderStyle = BorderStyle.None;
Graphics g1 = pb.CreateGraphics();
g1.FillRectangle(Brushes.BlueViolet,180,73,50,7);
this.Controls.Add(pb);
this.Refresh();
------解决方案--------------------PictureBox pb = new PictureBox();
pb.Location = new System.Drawing.Point(176, 72);
pb.Size = new Size(80, 13);
pb.BorderStyle = BorderStyle.FixedSingle;
Graphics g1 = pb.CreateGraphics();
g1.FillRectangle(Brushes.BlueViolet, 0, 0, 50, 7);
this.Controls.Add(pb);
this.Refresh();
这就看得到了
------解决方案--------------------估计是你的事件选择错了.