Remember the good old Forms collection in VB 6.0. How easy it was to enumerate through the Forms that were loaded. In .NET we don't have any such collection.
In .NET this can be achieved by adding a simple Class with a Shared member.VB Code:
Public Class FormsCollection Public Shared Forms As ArrayList = New ArrayList End Class
Now in the constructor of all the Forms writeThis will add the Forms to the collection whenever they are created in the memory.VB Code:
FormsCollection.Forms.Add(Me)
Now to loop through the collection we can useVB Code:
For Each f As Form In FormsCollection.Forms 'rest of code here Next
Remember when you close the Form you need to remove the Form from the Collection usingVB Code:
FormsCollection.Forms.Remove(Me)




Reply With Quote