Click here to Skip to main content
12,896,108 members (53,117 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# C#4.0
i have created text box dynamically. i am able to retrieve text value from text to store this value in array?? is it possible?

            foreach (Control c in panel1.Controls)
                if (c is TextBox)
                    TextBox txt = (TextBox)c;
                    string msg = txt.Text;
Posted 26-Sep-12 4:28am

1 solution

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

Solution 1

Just define an array in the appropriate scope and add the text from the textbox to it. ie. YourArrayObject.Add(YourTextValue);
I would highly suggest not using and Array[], but rather a List.
Sergey Alexandrovich Kryukov 26-Sep-12 11:15am
That's correct, my 5. I would only add that it could be any kind of container (generic List, etc.), and it should be defined and populated at the moment of "dynamic creation" of the controls. Generally, there is not such thing as a kind of mysterious "non-dynamic". The designer? No difference, but better don't use the designer to create a whole array of something or just many controls -- this is pure manual work, unlike your own code.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100