Best way to display a form inside another form?

1

I'm in doubt here, I do not know much about it.

1 I was using a form only, with several panel hidden inside it, and when the user clicked on any option in menuStrip I manipulated the Enabled and Visible properties % of the corresponding panels. But it was bugging, the database was not writing the typed content.

2 I tried using splitContainer , but it still has a bug, it does not save, but it takes too long to get the form and to save. I tried the code:

splitContainer1.Panel2.Controls.Clear(); // limpa o painel2
nvCli.TopLevel = false; // não alinha ao topo
nvCli.AutoScroll = true; // exibe barra de rolagem automaticamente
splitContainer1.Panel2.Controls.Add(nvCli); //add formulario ao painel 2
nvCli.Show(); // mostra formulario

Where nvCli is a static instance and publishes from another form. Another problem here is that the form was not being displayed in the center of panel2 , it was getting crooked.

Would you like to know if there is another better way to view or fix bugs?

Interface layout (yes, I did it in paint kk)

    
asked by anonymous 01.07.2015 / 18:15

2 answers

1

Hello, Leonardo. Is that okay?

I think it is of little advantage to use several forms within another, in addition to making the interface very complex, it tends to leave the code quite extensive.

Do you have a really good reason to do this? If not, I advise you to use forms with the same ShowModal, as long as there are not too many overlapping, or even keep several panels hidden and display them when needed.

The error of not saving in the bank needs to be evaluated as it is probably not related to the panels.

    
02.07.2015 / 16:34
1

It had a medium solution in the gambiarra style, you only have to leave the elements that should appear when the form is started visible and the rest (this hidden form) must be invisible (visible = false), and when the user clicks on this menustrip these elements would be visible.

It is a very "manual" and "inelegant" solution, but why have an elegant code, right? Just be sure that everything will work and you will understand everything later if you need to maintain the code.

    
03.07.2015 / 04:37