Naredla Nithesh

Naredla Nithesh

  • NA
  • 328
  • 77.1k

repositioning of controls in a panel control

Apr 23 2014 1:17 AM
 hi friends this is my code but in this when i click on  my delete button(this is also present in TimerUserControl) ,TimerUserControl will delete from the panel control list and remaining all controls are repositioned from top to bottom ...and i am unable to catch the index position of deleted TimerUserControl


private void btnAddTimer_Click(object sender, EventArgs e)
        {
            TimerUserControl obj_TimerUserControl = new TimerUserControl();
            obj_TimerUserControl.Name = "Timer" + count;
            obj_TimerUserControl.Location = new Point(5, count * 200);
            obj_TimerUserControl.Size = new Size(540, 180);
            bodyPanel.Controls.Add(obj_TimerUserControl);
            obj.Add(obj_TimerUserControl);
            count++;
            MessageBox.Show(obj_TimerUserControl.Name.ToString());
        }

        private void bodyPanel_ControlRemoved(object sender, ControlEventArgs e)
        {
            
            TimerUserControl tim = (TimerUserControl)sender;
           
            int index = obj.IndexOf(tim);
            for (int i = index; i < obj.Count; i++)
            {

                obj[i].Location = new Point(5, i * 200 - 200);

            }

        }

Answers (1)