Ahmet Ekrem SABAN
asked on
Windows Forms design question
Hello!
I am currently involved in my first WinForms project with C#. We are going to implement the GUI for a machine that consists of several menus. Below, you see the main menu that is the class currently all the forms are derived from. All the menus have the same "border", where I mean with border the button menu below, the status information to the left, the controls to the right and the header information.
As I have indicated above, currently, there exists a MainForm class that is used to derive the other forms for each submenu. Each of these forms repeat the "bordered" information.
This was the way my customer asked me to do it, but I doubt that it is really necessary to create different forms, as it may suffice to fill-in the central part according to the menu button pressed.
Question
Is the design of my application the right way to solve the problem, or should I leave the derived forms, using only one MainForm that has a varying central part?
Thank you for your suggestions!
I am currently involved in my first WinForms project with C#. We are going to implement the GUI for a machine that consists of several menus. Below, you see the main menu that is the class currently all the forms are derived from. All the menus have the same "border", where I mean with border the button menu below, the status information to the left, the controls to the right and the header information.
As I have indicated above, currently, there exists a MainForm class that is used to derive the other forms for each submenu. Each of these forms repeat the "bordered" information.
This was the way my customer asked me to do it, but I doubt that it is really necessary to create different forms, as it may suffice to fill-in the central part according to the menu button pressed.
Question
Is the design of my application the right way to solve the problem, or should I leave the derived forms, using only one MainForm that has a varying central part?
Thank you for your suggestions!
ASKER
I not only forgot to add the image of the display, but that the state of each form has to be retained all over the application life time. That is, if one is in menu three and returns to menu one, he finds everything as (s)he left it.
"... it may suffice to fill-in the central part according to the menu button pressed."
You can design the central part using UserControls or regular Forms (displayed with no Border). Then just swap out what is displayed in the middle.
*To embed a Form like a control in another Form, set its TopLevel() property to False at run-time via code.
You can design the central part using UserControls or regular Forms (displayed with no Border). Then just swap out what is displayed in the middle.
*To embed a Form like a control in another Form, set its TopLevel() property to False at run-time via code.
ASKER
But if I used regular forms for the central part, how can I merge the MainForm with the parts for the different menus? As far as I understood, this will be a borderless form that is placed exactly at the right position. But if one touches it and moves to another direction, the central part will be shifted.
Since it's borderless, the user won't be able to move it around. Additionally, you can set its Dock() property to Fill which would make it fill that entire area even when the main form is resized and/or moved.
ASKER
Currently, I am writing the functional description and I am involved in other tasks. So, I am sorry that you have still to wait for the test...
ASKER
Hello, Idle_Mind. Now, time has come to try this workaround...
Can you tell me how to create out of an existing Form a "regular form"?
Can you tell me how to create out of an existing Form a "regular form"?
ASKER
OK, I created the ValuesForm as an example, no more deriving it from BaseForm, but simply from Form. To get both the surrounding and the ValuesForm, I added a BaseForm object as a field. In my constructor of ValuesForm, I wrote
Not that this Form has a private constructor, as it is currently a singleton...
But the result is the BaseForm and the ValuesForm separated. By chance, they are overlaying, but when I click the BaseForm, the ValuesForm vanishes behind it. (ValuesForm cannot be clicked as BaseForm or moved by the mouse.) How can I use the Dock method so that the ValuesForm docks at the Location I need?
private ValuesForm()
{
[...]
m_BaseForm.Visible = true;
Location = new Point(220, 34);
m_BaseForm.Dock = DockStyle.Bottom;
FormBorderStyle = FormBorderStyle.None;
}
Not that this Form has a private constructor, as it is currently a singleton...
But the result is the BaseForm and the ValuesForm separated. By chance, they are overlaying, but when I click the BaseForm, the ValuesForm vanishes behind it. (ValuesForm cannot be clicked as BaseForm or moved by the mouse.) How can I use the Dock method so that the ValuesForm docks at the Location I need?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Congratulations, Idle_Mind! Only one line is missing!
Thank you very much, sir!
m_ValuesForm = ValuesForm.GetInstance();
m_ValuesForm.FormBorderStyle = FormBorderStyle.None;
m_ValuesForm.TopLevel = false;
panelForm.Controls.Add(m_ValuesForm);
m_ValuesForm.Show();
Thank you very much, sir!
>Below, you see the main menu
where can we see it?