Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Groupbox
 

Groupbox

hi all ,
id like to make one groupbox . In that gropbox should be few items such as 4 buttons ,2 lebles and 2 textbox.......
if i click on button4 than same groupbox display next to that one.
if i click 100 times so 100 same groupbox be in that frame.

plz help me .......
cheersssssssss
mtiesh patel  Tuesday, March 03, 2009 1:17 AM
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.
Felicitous  Tuesday, March 03, 2009 7:37 AM
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.
Felicitous  Tuesday, March 03, 2009 7:37 AM

You can use google to search for other answers

Custom Search

More Threads

• Datagridview refresh
• Databinding
• Line UserControl and Adorners
• Escape Button in a propertyGrid
• System.ComponentModel.Design.ExceptionCollection thrown in user control subclass
• properties set in the designer depend on each other
• Localized resources for Controls
• Custom editor on extender control
• Can't design a User control if not inherited directly from UserControl
• Question about UserControl