Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个表格布局面板,分为 4 列和 4 行。通过使用Panel box = new Panel();我用面板填充了所有 4x4 表格布局面板。现在我必须在示例中删除 2 列和 3 行中的面板。我怎么做?
Panel box = new Panel();
有几种方法可以做到这一点,但试试这个;
tableLayoutPanel.Controls.Remove(tableLayoutPanel1.GetControlFromPosition(col, row));
这是假设您只是想删除面板(因为它们将是 tableLayoutPanel 的子控件)。
否则,您可以通过该方法传递要删除的实际面板来直接删除;
tableLayoutPanel.Controls.Remove(panelYouWantToRemove);