I have a form where I have a list with objects stored. I then have a dialog in which I wish to access this list and loop through its content.
The main form:
namespace personregister
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public List<person> personStorage = new List<person>();
In the dialogue I want to do something like this:
namespace personregister
{
public partial class AddPersonDialogue : Form
{
public AddPersondialogue()
{
InitializeComponent();
foreach (person p in personStorage)
{
//do stuff
}
}
problem is that I cannot access personStorage which I created in the other form. How do I access that list in the dialogue window?
Add a method to do the dialoge and call after it is constructed.
You could also do it via the constructor.