Display form in the middle of splitContainer Pinel?

Asked

Viewed 97 times

0

I’m using the following code to call and show the form in the 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 way out is being: inserir a descrição da imagem aqui

I wanted to know how I line up form to the center of my panel2, being like this: inserir a descrição da imagem aqui

Or occupying the panel2 whole.

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

1 answer

0


I managed to solve, the problem would be the anchors that were like top,left, then no matter what I did he always carried the contents to the top left. I also added a code to resize my form to stay the same size as the 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;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.