Nested GroupBoxes

  • Thread starter Thread starter jagrat
  • Start date Start date
J

jagrat

I am having a Tab Page where I need to place nested GroupBoxes. Based
on an XML file, I get the information about the size, loocation and
Name for the GroupBoxes.

I create a GroupBoxes and make one as Child of another.

I am able to see the Parent GroupBox on the Tabpage but cannot see the
child GroupBox. What can be the problem?

Thanks in advance.

Jag
 
Not sure I understand what you're saying.

If you're creating the GroupBoxes at run time, be sure to set the Parent
property.

parent.Controls.Add ( child )

or

child.Parent = parent
 
To explain/clarify my problem further:

I have a tabpage Tp. and a ControlList cl[5];

Something similar to my real code will be :

cl[0] = new GroupBox();

//setting all the properties for cl[0]
// cl[0].suspendlayout()

Tp.controls.Add(cl[0]);

cl[1] = new GroupBox();

//Setting all the properties for cl[1]

cl[0].controls.Add(cl[1]);

cl[0].resumelayout(true);

I can see cl[0] on the Tab Page, but am unable to see the cl[1] inside
cl[0].

Please help.
 
Are you setting the sizes and positions?

System.Windows.Forms.GroupBox g1 = new System.Windows.Forms.GroupBox() ;
g1.Name = "G1" ;
g1.Top = 8 ;
g1.Left = 8 ;
g1.Size = new System.Drawing.Size ( 100 , 100 ) ;

System.Windows.Forms.GroupBox g2 = new System.Windows.Forms.GroupBox() ;
g2.Name = "G2" ;
g2.Top = 8 ;
g2.Left = 8 ;
g2.Size = new System.Drawing.Size ( 80 , 80 ) ;

this.Controls.Add ( g1 ) ;
g1.Controls.Add ( g2 ) ;
 
Also remember that the position of the child control is relative to the
top=left of the parent control, not of the form.
 
THANKS A LOT PIEBALD,

I was setting the location relative to the parent node. That was
creating the trouble.

Thanks once again for your help.

Jag
 
Back
Top