I have a tablelayoutpanel divided in 4 columns and 4 rows. by using Panel box = new Panel(); I filled in all 4x4 tablelayout panel with panels. now I have to delete in example a Panel which is in 2 collumn and 3 row. how do I do that?

有帮助吗?

解决方案

There are a few ways to do it, but try this one;

tableLayoutPanel.Controls.Remove(tableLayoutPanel1.GetControlFromPosition(col, row));

This is assuming you're just trying to remove the panels (As they would be child controls to the tableLayoutPanel).

Otherwise you could remove directly by passing the actual panel you want to remove through the method;

tableLayoutPanel.Controls.Remove(panelYouWantToRemove);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top