From this post link: http://devcity.net/articles/94/1/.aspx, you can find there are 7 ways to tracking and interaction other forms:
However, I am still not conformable those ways to handle the forms. I am reading this book: Pro .NET 2.0 Windows Forms and Custom Controls in VB 2005, and I find below is the way which is pretty suitable for most of my applications:
Visual Basic includes a shortcut that allows you to communicate between forms, Each form has a default instance, a form object that's created automatically when needed. The best way to use the default instance is through the My.Forms object, which is hard-wired into the VB language. For example, if you have the form classes Form1, Form2, and Form3, you can access their default instances through the My.Forms.Form1, My.Forms.Form2, and My.Forms.Form3 properties:
This code accesses the default instance of From1 and calls the Show() method. Here's the interesting bit: VB uses a lazy creation technique to generate default instances. That means that the default instance is instantiated when you refer to it for the first time. As a result, the line of code shown above may or may not create Form1. If the default instance of Form1 hasn't been created yet, it will be instantiated automatically. On the other hand, if the default instance has already been created, no instantiation is required. Also, if two different forms use above code, it won't create two same Form1s, only one instance.
Above code is create a form object implicit rather than explicit. To create explicitly, we need do this:
Don't mix implicit and explicit in your code, otherwise, will create two objects for the same Form1 class, and ends up one form is updated, and another form remains out of reach.
|