Display form in the middle of the splitContainer's pinel?

0

I'm using the following code to call and show form in panel2 of my splitContainer :

splitContainer.Panel2.Controls.Clear(); // limpa o painel2
form.TopLevel = false; // redefine lvl do form
splitContainer.Panel2.Controls.Add(form); //add formulario ao painel 2
form.Show(); // mostra formulario

And the output is:

Iwantedtoknowhowtoalignformtothecenterofmypanel2,thus:

Or occupying panel2 everything.

I already tried to start form as maximized, and to the center changing properties of it and it did not work.

    
asked by anonymous 03.07.2015 / 06:44

1 answer

0

I was able to solve it, the problem would be the anchors that were like top,left , so it did not matter what I did it always took the contents to the top left. I also added a code to resize my form to be the same size as panel

int altura = this.NOME-SPLIT-CONTAINER.NOME-DO-PANEL.Height;
int largura = this.NOME-SPLIT-CONTAINER.NOME-DO-PANEL.Width;
FORM.Height = altura;
FORM.Width = largura;
    
03.07.2015 / 18:19