How can I loop through all the open instances of a particular form?
Posted
by
raz3r
on Stack Overflow
See other posts from Stack Overflow
or by raz3r
Published on 2011-01-10T12:15:29Z
Indexed on
2011/01/10
12:53 UTC
Read the original article
Hit count: 115
I need to update a ListBox of a Form2 created dinamically. Let's say that in the event where I have to update this ListBox (in Form1 of course) I don't have a reference of this Form2 so I can't call the UpdateList method (and no, I can't make it static). I don't even know if there is a Form2 opened, it could be or not. What do you suggest? Is there a way to loop through all the open istances of Form2?
Code Sample:
//Form1
public void event()
{
//UPDATE FORM2 LISTBOX
}
//SOMEWHERE IN FORM1
Form2 runTime = new Form2();
//Form2
public void UpdateList()
{
//UPDATE LISTBOX
}
© Stack Overflow or respective owner