简体   繁体   English

C#tablelayoutpanel面板控件

[英]C# tablelayoutpanel panel control

I have a tablelayoutpanel divided in 4 columns and 4 rows. 我有一个tablelayoutpanel分为4列和4行。 by using Panel box = new Panel(); 通过使用Panel box = new Panel(); I filled in all 4x4 tablelayout panel with panels. 我用面板填充了所有4x4桌面版面板。 now I have to delete in example a Panel which is in 2 collumn and 3 row. 现在我必须删除2列3行的Panel。 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). 这是假设您只是尝试删除面板(因为它们将是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 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM