Skip to content

Repositioning of controls in a panel control

Naredla Nithesh

Naredla Nithesh

Asked Apr 22, 2014, 9:17 PM EDT1 answer
Share
LinkedInX
 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);

            }

        }

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 1 short reply
    • Naredla Nithesh
      0
      i did it.
      0