最大化tablelayoutpanel的面板

编程入门 行业动态 更新时间:2024-10-25 01:30:09
本文介绍了最大化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的面板

本文发布于:2023-11-29 18:27:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647235.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:面板   tablelayoutpanel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!