Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
i have a windows formin which there is a button1 clicking
the button a user control is added dynamically on a panel1.
in that usercontrol there are 4 control
combobox1, combobox2, textbox1,textbox2
and there is 4 more control on the windows form which is phonemanu phonemo imietextbox and faultextbox
one more button2 when button is click it transfer
all the text to a new form which is newcustomer
i want that in this form
new.phonemanu must be (phonemanu,combobox1,combobox1,etc all the dynmaically generated combobox1)
new.phonemo must be (phonemo,combobox2,combobox2,etc all the dynmaically generated combobox2)

i have generated this code but it only shows (phonemanu.text , last generated combobox1)
and all the middle combobox text is not add.. why i dont know
 
this is my code
 
newcustomer new1 = new newcustomer();
                foreach (Control ctrl in panel1.Controls)
                {
                    if (ctrl is UserControl1)
                    {
                        UserControl1 myCrl = ctrl as UserControl1;
                        new1.phonemanu.Text = phonemanu.Text + "," + myCrl.comboBox1.Text;
                        new1.phonemo.Text = phonemo.Text + "," + myCrl.comboBox2.Text;
                        new1.imeitextbox.Text = imeitextbox.Text + "," + myCrl.textBox1.Text;
                        new1.faulttextbox.Text = faulttextbox.Text + "," + myCrl.textBox2.Text;
                        
		    }
                 }
Posted 4-Jan-13 5:52am
Edited 4-Jan-13 6:40am
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

If they are dynamically generated, then they won't have properties, right ? In general, exposing controls like this is bad. Expose a method that looks up the dynamic controls, and returns the text you want returned.
  Permalink  
Comments
shaikh-adil at 4-Jan-13 14:18pm
   
can you code and explain?? and in my project i dont want any security then can you simply how can i obtain in simple..
Christian Graus at 4-Jan-13 17:23pm
   
You don't ever access the controls on your user control. You call a method. You need to do this anyhow, because you need to look up this dynamic control and get values from it. But, it's also best practice
sariqkhan at 4-Jan-13 14:44pm
   
http://www.codeproject.com/Questions/521783/howplustoplustransferplustheplustextplusfromplusdy
sir can you help me here please if you can

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 469
1 OriginalGriff 379
2 CPallini 205
3 Sergey Alexandrovich Kryukov 170
4 Sharmanuj 109
0 OriginalGriff 5,649
1 Sergey Alexandrovich Kryukov 4,783
2 Peter Leow 2,954
3 Maciej Los 2,689
4 DamithSL 2,465


Advertise | Privacy | Mobile
Web02 | 2.8.140718.1 | Last Updated 4 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid