示例#1
0
 private void button2_Click(object sender, EventArgs e)
 {
     rfFieldTextBox f1 = new rfFieldTextBox();
     f1.Dock = DockStyle.Top;
     this.panel1.Controls.Add(f1);
     this.panel1.Height += 41;
     this.Height += 41;
 }
 //public delegate void AddControlToPanelHandler(Panel p, string c);
 public void AddControlToPanel(string label,string text,int tab,bool isrequired,string fieldmember)
 {
     string name = label + tab.ToString();
     rfFieldTextBox control =null;
     bool isexist=false;
     foreach (Control item in this.bodypanel.Controls)
     {
         if (item.Name == name)
         {
            control=item as rfFieldTextBox;
            control.SetText(text);
             isexist=true;
             break;
         }
     }
     if (isexist)
     {
         control.DataBinding(this.receivelinereq, fieldmember);
     }
     else
     {
         control = new rfFieldTextBox(label, text, tab, isrequired);
         control.Name = name;
         control.DataBinding(this.receivelinereq, fieldmember);
         this.bodypanel.Controls.Add(control);
         this.bodypanel.Controls.SetChildIndex(control, 0);
         control.Dock = DockStyle.Top;
         this.bodypanel.Height += 39;
     }
 }