I'm trying to open a form inside another form, but I'm having some difficulty.
The idea is that when you click on the "btn_CadastroAlunos" button the form "F_Cadastro_Alunos.vb" opens in panel1 that is present in the main form "F_Principal.vb"
My code looks like this in the Click event of the button ("btn_CadastroAlunos"):
Dim NovoForm As New F_Cadastro_Alunos
NovoForm.TopLevel = False
NovoForm.Visible = True
Panel1.Controls.Add(NovoForm)
NovoForm.Show()
However, when you perform the button click operation, the following error is returned:
System.ArgumentException: 'Only the top-level controls can have an owner. Arg_ParamName_Name '
The following image explains the error generated when trying to display the form:
Does anyone know what the solution is ?! Thanks in advance for your attention!
Note: I am using the framework: Moden UI