日期:2014-05-18  浏览次数:20981 次

动态创建控件的显示问题
如下代码:
 // 
  // pnlPhone
  // 
  pnlPhone = new Panel();
  pnlPhone.BackColor = System.Drawing.Color.FromArgb(255, 204, 204, 204);
  pnlPhone.Location = new System.Drawing.Point(28, 20);
  pnlPhone.Margin = new System.Windows.Forms.Padding(2);
  pnlPhone.Name = "pnlPhone";
  pnlPhone.Size = new System.Drawing.Size(405, 303);
  pnlPhone.TabIndex = 27;
  pnlPhone.BorderStyle = BorderStyle.FixedSingle;
  //
  //pnlTime
  //
  pnlTime = new Panel();
  pnlTime.BackColor = System.Drawing.Color.Red;
  pnlTime.Location = new System.Drawing.Point(28, 20);
  pnlTime.Margin = new System.Windows.Forms.Padding(2);
  pnlTime.Name = "pnlTime";
  pnlTime.Size = new System.Drawing.Size(405, 50);


  controlForm是一个窗体:
  controlForm.Controls.Add(this.pnlPhone);
  controlForm.Controls.Add(this.pnlTime);


现在的问题是pnlTime显示不出来,貌似是被pnlPhone遮挡了。 该如何解决

------解决方案--------------------
探讨

引用:
pnlTime.Location = new System.Drawing.Point(28, 20);
pnlPhone.Location = new System.Drawing.Point(28, 20);

你两个控件都定位在相同的位置上,自然如此。
就得在相同位置上绘制, 有没有动态设置前置后置的代码?