I have built a touch screen application using Windows Forms.
It works great but I still would like to have some design advice.
My application consists of several different windows forms.
My design is that I have one MainForm which all of the other forms inherit from. In this Mainform I have the buttons where the user can choose which form to open.
When the user chooses one of the options another form is opened. I use the following code:
Control control = this; // the current form, that is open
Recording rec = Recording.Instance; // the form that the user choose to open
if (control != rec) {
rec.Show(); // show the recording form
control.Hide(); // hide the previous form
}
Is this a correct way to work with forms or should I use some other way? For example, have one form and user controls in it.
A few things I noticed:
Recording.Instance. That looks to me like you are making these forms singleton. That can work, but I’d rather see them created/closed as needed.rec.Show();This is a nitpick, but a lot of the time you want to pass the current form as an owner:rec.Show(this);orrec.Show(control);.