1
I have two presses (FormMenuPrincipal
and FormFuncionarios
) in which when the button btnFuncionarios
of Menu is clicked, I want to open the form Employees. I thought I’d add one panel painel
as follows:
private void btnFuncionarios_Click(object sender, EventArgs e)
{
FormFuncionario janela = new FormFuncionario();
janela.Visible = true;
painel.Controls.Add(janela);
}
But when running, Visual Studio points out the following error:
An unhandled Exception of type 'System.Argumentexception' occurred in System.Windows.Forms.dll
Additional information: Unable to add level control superior to a control.
The error occurs exactly on the line where I am adding the form inside the panel. What’s wrong ? There is another easier method to do this ?
Remembering that the two Forms cited are "normal" and I don’t want to add exactly in the middle, I want to add it in a certain area.
It worked ! You would know how to tell me how to let the form take up all the space (height and width) of the panel ?
– Daniel Santos
I believe it is simple, just set the width and height of the form
janela
paritr of panel width and height values...– Diego Rafael Souza
See if this solves Window.. Windowstate = Formwindowstate.Maximized;
– Paulo Ricardo
It worked man, thanks a lot !
– Daniel Santos