I have my form embedded on top of the tabpage. When I closed the form which is on top of the tabpage, how do I also make the tabpage close as well?
The code when I put my form on the tabpage is more less like this:
client c = new client(car_name, owner); //here client is another winform class
c.TopLevel = false;
c.Visible = true;
c.BackColor = Color.Ivory;
c.FormBorderStyle = FormBorderStyle.None;
c.Dock = DockStyle.Fill;
tabControl1.TabPages[tab_index].Controls.Add(c);
Use the FormClosing event :
private void ClientForm_FormClosing(object sender, FormClosedEventArgs e)
{
((TabControl)((TabPage)this.Parent).Parent).TabPages.Remove((TabPage)this.Parent);
}