Hi,
You can add the controls dynamically. So, first create a panel and put your group box and other controls in it. Copy the code(code for panel and group box) from the designer part where the panel and group box controls were created. Then initialize a variable (e.g int i=0 globally) so that you can provide different names to your panel as well as group box controls.
Add those code to the click event of the button. So, each and every time you click the button a panel will be added to the form with all the controls
Code e.g Arraylist labels = new ArrayList(); this.labels.Add(new Label()); ((Label)this.labels[i]).Location = new System.Drawing.Point(15,35); ((Label)this.labels[i]).Name = "lbl" + label; ((Label)this.labels[i]).Size = new System.Drawing.Size(63, 21); ((Label)this.labels[i]).TabIndex = i + 2; ((Label)this.labels[i]).Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold); ((Label)this.labels[i]).Text = label;
So, in this manner you can create panel and other controls. And then you can add all the controls to the panel. - Marked As Answer byLing WangMSFT, ModeratorMonday, March 09, 2009 11:50 AM
-
|