i have a windows form in which there are controls listed below panel1 button1 = add new mobiles button2 = ok When clicking on button1 an usercontrol is added. You can add as much userControls as you wish. The userControl defines consists of five controls:
combobox1 combobox2 textbox1 textbox2 textbox3
i want to add the text of textbox3 of all the dynamically generated usercontrol control and set to a label on the winform how can i do that? by clicking the ok button i have tried this code
foreach (Control ctrl in panel1.Controls)
{
if (ctrl is UserControl)
{
UserControl1 myCrl = ctrl as UserControl1;
int g;
// but this doesnt happen an error is coming
g += Convert.ToInt32(myCrl.textbox3.Text);
}
}
how to get sum of all the dynamically generated control's text
g
outside theforeach
– Pilgerstorfer Franz