I have a form (Form1) and a button on it. When I press that button, I create runtime panels stored in an array of panels, declared like that:
Panel[] Panouri_variabile = new Panel[20];
If I press the button, a panel is created. If I press the button again, another panel is created underneath the previous panel and so on.
Each panel has a textbox inside it. Obviously, the textboxes are stored in an array of textboxes, declared like that:
TextBox[] Nume_variabila = new TextBox[20];
The user writes something in each textbox of each panel.
Now, I want to access the data written by the user in those textboxes, from another form, like that:
Form1 form = new Form1();
form.Panouri_variabile[i].Nume_variabila[i].Text
That could be easily done if the panels and the texboxes are created at design-time, by simply setting the Modifier property of all controls to public.
The problem is that they are created at run-time, so I can't change the Modifier property.
After a lot of searches I found the following posible solution:
Panel new_Panel = Panouri_variabile[i];
And then declare the following property at the same level as the event - handlers are (class-level I think)
public Panel new_Panel { get; private set; }
I noticed that I can see the new_Panel from another form, so I can access it like that:
Form1 form = new Form();
form.new_Panel
but the problem that it is not indexable! I have an array of panels (and an array of texboxes) so I should access them using an index, as I specified above!
Is there a way of accessing those texboxes from another form? Or should I create them design-time?