Navigating Forms

zrenzi

Member
Joined
Apr 13, 2007
Messages
7
Programming Experience
1-3
Hello,

I did a search on this topic and found some things, but nothing that was specific. I have a group of forms, in each form I have navigational forward and back buttons in the toolstrip. I wanted to know if there was an easy way to make these buttons function properly. Any help would be appreciated. If someone could point me in the right direction it would be a big help.
 
It depends on what you are doing. If anything on forms change then you sould hide the form rather than unload it. In the button click event put
Form2.Show
Form1.Hide
Make sure that in the projects property section you select the shutdown mode as "When last form closes". This is for vb 2005. Other versions are probably different.
 
Thanks for the reply. I am aware of showing and hiding forms though. I was hoping there was something a bit more sophisticated. When you have 20 or 30 forms as part of a project it can be tedious to have to put code directing you to different forms all of the time -- it also leaves more room for error. Thanks again.
 
I think I would set up a shared LinkedList(Of T), T is the type and in this case Form, the purpose is that each item contains reference to previous and next item in list. Add an instance of each form to this list (the default instances perhaps), each form can then access this shared list to Find itself and easily call its Previous/Next. You can even remove/insert items and still have the linked chain preserved.

Another option might be using Application.OpenForms collection.
 
Back
Top