private void train_button_Click(object sender, EventArgs e) { loading_form lf = new loading_form(); lf.Show(); lf.Form_Shown(); List <Control> delete_list = new List <Control>(); foreach (Control con in main_tab_control.TabPages[2].Controls) { if (con is Panel && con.Name.Contains("panel_new_")) { delete_list.Add(con); } } for (int c = delete_list.Count - 1; c > -1; --c) { main_tab_control.TabPages[2].Controls.Remove(delete_list[c]); } clear_folder("temp_data"); train_title_label.Text = "Trained"; train_button.Enabled = false; }