Question

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?

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top