A form within a form
Inserting a form within another form has it uses at certain points whether it’s intentionally done or it’s made in a sense where it would only be used in certain conditions and the code to implement it is quite simple.
Let's take a look at the following code
So essentially what we’re doing is loading the form as if it was a control and in turn we’ll need a container where to load it, in this case I’m using a tab control, as we wouldn’t want to take up the whole space of the form as that would just be wasting resources.
So going a bit into the code, first we create a new instance of the form that we want to insert and then change the settings so that it doesn’t contain any Form Borders and that it fills the container where it is going to be inserted. The last step is to add the instance of the form as if it was a control.
Now, why would you want to add a form within another form? Well cases where it’s intentionally done are a tabbed web browser or text editor or where several different things need to be displayed. A case where it wouldn’t be intentionally could be like having a form which may load a certain view where it needs to show data from other forms.