I keep forgetting how this is done..
I want to update the UI on the main form from Form2 without creating an instance of the form.
I remember using a delegate / event and possibly passing in an instance of the first form somehow, but totally went blank.
Help me out, thanks.
Add something to listBox1 on Form1 from Form2.
Its hard to get exactly what you need from the question, but it sounds like you could pass an Action to your form for adding the items. You could change the constructor in Form2 to ensure you always have the callback - e.g.
You cannot update an object that you did not instantiate.
What you can do is either register some function as handler for a change event in form2. If the function is a member of the main form it can then affect the components of that form.
Passing a delegate is basically the same but would allow you to use an arbitrary function of your choosing. Most of the time this is not worth the overhead, though.
Yes, delegate and event are correct key words
Implement your EventArgs class somewhere:
In Form2:
In Form1: