In my program, I inserted a button and a panel
. When the button is clicked, logic inserts another form in panel
overlapping form
initial.
No form2
that appears has a return button, which causes form2
to add up and reappear form1
, but no code I try to use is working. The button code is as follows:
//FORMULÁRIO CONTEUDO
this.panel1.Controls.Clear();
Conteudo frm = new Conteudo();
frm.TopLevel = false;
panel1.Controls.Add(frm);
frm.FormBorderStyle = FormBorderStyle.None;
panel1.Height = this.Size.Height;
panel1.Width = this.Size.Width;
frm.Size = new Size(this.panel1.Width, this.panel1.Size.Height);
Application.DoEvents();
frm.Location = new Point(0 + this.panel1.AutoScrollPosition.X, 0 + this.panel1.AutoScrollPosition.Y);
panel1.BringToFront();
panel1.Visible = true;
panel1.BackColor = Color.WhiteSmoke;
frm.Show();
And in form2
, on the button, I used the following code, and so many variants:
Form2 frm = new Form2();
frm.Controls.Clear();
this.Close();
frm.Refresh();
If you can help me, I really appreciate it. The part of opening the form is working, but the return button to form1
does not work, when I can, using the above code, form 1 is only white.