Group Box

M

Madhavi

I Dynamically generate Controls on a groupBox

but i have to Enable a button when the dyanmic controls generated are
checked

so i loop them

foreach(System.Windows.Forms.Control temp6 in Controls)
{
kkkkkkk
enableButton = true;
}


But the problem here is Controls does not contain the names of the
dynamic Controls that were genareated on the groupBox . It traverses
thrugh group box and Buttons available on the form.

If i write another loop within as follows
foreach(System.Windows.Forms.GroupBox transtemp7 in groupBox )
an error occurs stating the
Error 1 foreach statement cannot operate on variables of type
'System.Windows.Forms.GroupBox' because 'System.Windows.Forms.GroupBox'
does not contain a public definition for 'GetEnumerator'

Can somebody help me how to traverse controls in a group Box
 
K

Kevin Spencer

Add the Controls to the Controls Collection of the GroupBox. Not only does
this enable you to loop through the Collection, but enables you to Dispose
of each Control if and when it is removed.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

What You Seek Is What You Get.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top