C#C
C#10mo ago
Mìscha

Switching between forms in WinForm app

Hey,
I'm trying to create a small little data managment app, and I've got most of the stuff figured out, but I have a problem with one of my desired solutions.
The app has a side bar with menu items, and a listview.
The menu buttons should change what data is being shown in the list view.
To do this I can imagine 2 solutions.
Sol 1 is to reformat the list view and stuff it with new data.
Sol 2, which is where I have problems, is having a few forms laying about, with their own formatted and data filled ListViews, but I get a little confused on how to do it.
I've seen https://stackoverflow.com/questions/9462592/best-practices-for-multi-form-applications-to-show-and-hide-forms where Zev Spitz does a good job at describing a FormManager,
My confusion with his explanation is if I should do "var f3 = new Form3();" in the Form Manager constructor whenever I need a new form for a button, of if this is called in the MainForm.cs
Anyone with any knowledge on the handling of multiple forms in winform apps is greatly appreciated 😄
Stack Overflow
There are tons of questions on StackOverflow asking how to hide Form1 and show Form2. And, usually, a few different answers crop up:

1)

// Program.cs
Application.Run(new Form1());
// Form1.cs
Form2
Was this page helpful?