Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have a main form which I would like to use as a container for a header section, menu section and then the rest of the area will be used to display a form based on either the menu selection or a previous form selection. There will be only one form displayed at a time in this section.

I have the borderless forms created, but need to know how to link the menu button clicks to displaying the forms in the "Form Display" area. Should I use a panel? And what is the button click code to usein VB 2010?


<img src="http://i36.photobucket.com/albums/e23/jharding08/Layout_zpsb0900284.png" border="0" alt=" photo Layout_zpsb0900284.png"/>
Posted

Not too sure what the button click code would be. However I would go with a User Control because I don't believe you can have a Form within a Form. Here is what the code for the button clicks would probably look like:

VB
function button1_click
    DispalyPanel.Controls.Remove(Control2)
    Control2.Dispose()
    DispalyPanel.Controls.Add(Control1)
end function


You may have to set the display settings (such as fill and dock) in each click event to make the control fill the panel.
 
Share this answer
 
You need to use a set of panels with certain values of the property Control.Dock. The value for each case should be apparent from here (avoid using the default None):
http://msdn.microsoft.com/en-us/library/system.windows.forms.dockstyle(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dock%28v=vs.110%29.aspx[^].

Moreover, you should better use a number of inner panels, say, for your buttons and other things. You need to combine Dock with Control.Padding property:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.padding(v=vs.110).aspx[^].

—SA
 
Share this answer
 
Looks like that is the way to go. Thank you for your help
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 26-Aug-14 19:12pm    
Sorry, this is not an answer; such posts are considered as abuse. If you add an answer, it should be an answer, or some kind of help provided for a person who asked the question.
Besides, we are not getting notifications on your post.
Please use comments instead, and/or "Improve question" (above, below your question).

Are you going to accept any of the answers formally (green "Accept" button)? In all cases, your follow-up questions will be welcome.

—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900