最大化tablelayoutpanel的面板 [英] Maximizing a panel of a tablelayoutpanel
问题描述
在TableLayoutPanel中,我需要通过双击来最大化面板。我的意思是它成为一个面板控件,其他人暂时隐藏。在这种情况下,表格布局面板控件获得一个控件,该控件仅包含一个面板或仅显示一个面板填充其中。然后,如果再次双击现在最大化的面板,则会再次显示原始面板表。有没有直接的方法来达到这个目的?我能做些什么来更好地操纵它?
我尝试过:
现在我手动从TableLayoutPanel控件中删除控件,然后在恢复后重新创建它。但是这种方法有副作用,我需要避免。
在下一次尝试中,我将代码更改为:
In a TableLayoutPanel I need to maximize a panel by double-clicking on it. I mean it to become a one panel control and others get temporarily hidden. In this case, the table layout panel control gets a control which includes only one panel or shows only one panel which fills inside it. Then if the panel which is now maximize will be double-clicked again, the original table of panels appear again. Is there any straightforward way for this purpose? What can I do to manipulate it better?
What I have tried:
Now I manually remove controls from the TableLayoutPanel control and then recreate it after going to restore. But this method has side-effects which I need to avoid.
In the next try, I changed the code to:
private int _columnCount, _rowCount;
private void player_DoubleClicked(object sender, IDisplayable displayable)
{
if (tableLayout.ColumnCount == 1 && tableLayout.RowCount == 1)
{
tableLayout.ColumnCount = _columnCount;
tableLayout.RowCount = _rowCount;
foreach (var ctrl in tableLayout.Controls)
{
var panel = ctrl as UserControl;
if (ctrl != sender)
panel.Visible = true;
}
}
else
{
foreach (var ctrl in tableLayout.Controls)
{
var panel = ctrl as UserControl;
if (ctrl != sender)
panel.Visible = false;
}
_columnCount = tableLayout.ColumnCount;
_rowCount = tableLayout.RowCount;
tableLayout.RowCount = 1;
tableLayout.ColumnCount = 1;
}
}
推荐答案
你可以使用Control.Visible Property(System.Windows.Forms)| Microsoft Docs [ ^ ]显示或隐藏它。
You can use the Control.Visible Property (System.Windows.Forms) | Microsoft Docs[^] to show or hide it.
这篇关于最大化tablelayoutpanel的面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!