private void m_btnAdd_LinkClicked(object sender, EventArgs e) { m_panelControls.SuspendDrawing(); CControlEditeParametreDeFiltreData ctrl = new CControlEditeParametreDeFiltreData(); ctrl.NumParametre = m_panelControls.Controls.Count + 1; m_panelControls.Controls.Add(ctrl); ctrl.Dock = DockStyle.Top; ctrl.BringToFront(); ctrl.Valeur = ""; ctrl.OnDelete += new EventHandler(ctrl_OnDelete); m_panelControls.ResumeDrawing(); }
void ctrl_OnDelete(object sender, EventArgs e) { m_panelControls.SuspendDrawing(); CControlEditeParametreDeFiltreData ctrl = sender as CControlEditeParametreDeFiltreData; if (ctrl != null) { int nParametre = ctrl.NumParametre; m_panelControls.Controls.Remove(ctrl); ctrl.Visible = false; ctrl.Parent = null; ctrl.Dispose(); foreach (CControlEditeParametreDeFiltreData ctrlTmp in m_panelControls.Controls) { if (ctrlTmp.NumParametre >= nParametre) { ctrlTmp.NumParametre = ctrlTmp.NumParametre - 1; } } } m_panelControls.ResumeDrawing(); }