I have a
List<MyController> _myController = new List<MyController>();
this MyController object class holds 4 textboxes and 1 button and 1 checkbox.
The function of checkbox is to delete an entire row and remove it from the List Array of MyController object.
When I click checkbox it deletes the entire row but I want开发者_开发技巧 my entire cells to be redrawn on my Form.
I tried
Form.ActiveForm.Controls.Clear();
foreach(MyControls mcc in _myControls)
{
Form.ACtiveForm.Controls.Add(mcc.cb);
....
}
Form.ActiveForm.Update();
However, this does not change the locations. What is the best method for such a code in order to redraw form elements in properly updated locations once a line of elements deleted?
I hope I explained my question explicitly.
Try by using FlowLayoutPanel, add MyController into a normal Panel control, and then add this Panel control to the FlowLayoutPanel control. When you want to remove MyController, remove the normal Panel control as well, then the FlowLayoutPanel should re-arrange the remaining controls properly.
精彩评论