How to keep information in textboxes of a child form that was loaded in TableLayoutPanel?

Viewed 44

I need to keep the information that was entered in textboxes even if the user opened another child form,

for example: let's say we have 2 forms to be loaded in the same cell of a TableLayoutPanel

  1. the user entered the required information BUT they clicked on a button to open another form for any reason.

2.when they back to continue then the form is new and empty then they have to re-enter all the information again.

how to avoid that, and please take a look at my code (does it need any modifications for the same purpose).

bool isChildAlready = false;
string childName = null;

private void button12_Click(object sender, EventArgs e)
        {
            frmEmp chld = new frmEmp();
            loadChild(chld);
        }
        private void loadChild(Form child)
        {
            if (isChildAlready)
            {
                if (child.Name != childName)
                {
                    this.tlbMain.Controls.RemoveAt(1);
                    child.TopLevel = false;
                    child.BackColor = this.tlbMain.BackColor;
                    child.Dock = DockStyle.Fill;
                    this.tlbMain.Controls.Add(child, 1, 0);
                    child.Show();
                    isChildAlready = true;
                    childName = child.Name;
                }
            }
            else
            {
                child.TopLevel = false;
                child.BackColor = this.tlbMain.BackColor;
                child.Dock = DockStyle.Fill;
                this.tlbMain.Controls.Add(child, 1, 0);
                child.Show();
                isChildAlready = true;
                childName = child.Name;
            }
        }

Thank you.

0 Answers
Related