One ... simplified ... strategy to show a second Form when your 'View' button is clicked on your main Form:
private Form2 viewForm;
viewForm = new Form2();
viewForm.Owner = this;
if (viewForm.WindowState == FormWindowState.Minimized)
{
viewForm.WindowState = FormWindowState.Normal;
}
viewform.Show();
things to consider in your solution:
0. think about getting a good WinForms book for a thorough review of child-forms, owned-forms, MDI, multi-document form architecture, effects of FormBorderStyle, FormWindowState, ControlBox, etc. my favorite authors are Jesse Liberty, Matthew McDonald, and Chris Sells.
1. whether or not to have the owned form have minimize, maximize, control box, adornments
2. whether or not to have the owned form show in the TaskBar
3. whether or not to create the owned form once, and never allow it to be closed, or, if you do allow it to be closed, what you need to do to re-create it ad hoc
detailed comments:
1. There is, indeed, a possible child-parent relationship between Forms: A child Form of another Form is visually contained inside its parent Form. This relationship is a fundamental part of the Control object from which Forms inherit.
2. The owner-owned relationship simply means that owned Forms are displayed, hidden, minimized, etc., with their owner Form. Typically this relationship is used for a "floating window," or when you don't want any other Form to get visually "between" the shown Form and its owned Forms.
Note: both owner and owned Forms can be moved anywhere on the screen, can be re-sized, independently of each other. The owned Form can be minimized independently of its owner Form, but minimizing the owner Form will automatically minimize all owned Forms (and they will not appear in the TaskBar: even when the ShowInTaskBar property of the owned Forms is set to 'true).
3. The example code from SAKryukov above, under the heading "more accurate code" ... if used inside the Program.cs file of a Windows Form project ... will build, but will cause an error at run-time when you close the MainForm: it will never open Form2:
a. when Application.Run opens the MainForm it enters an event-loop that persists until MainForm is disposed.
b. when MainForm is disposed ... when it is closed by a user ... then, and only then, is any code after Application.Run executed.
c. so, at the moment it reaches the line where adding the new Form2 to the owned Forms of MainForm: MainForm no longer exists, and the application will throw an error.