用户控件的页脚面板可见C# [英] User Control's Footer Panel Visible C#

查看:89
本文介绍了用户控件的页脚面板可见C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户控件,将面板放在底部,此面板包含一些控件。我希望在某些情况下在运行时看不到这个面板但是当我这样做时在可见的父用户控制主体下,我想让我的表单显示在我可以做什么?请帮助我...谢谢

I Have A User Control that put a panel on Bottom of it , this panel Contains Some Controls . I Want To Invisible This Panel In Some Cases At Run time But When I do That Under This Panel visible Parent User Controls Body , I wanna to have my forms to show under that What Can I Do ? Please Help Me... Thanks

推荐答案

这里有一个完整的WinForms可折叠UserControl示例(源文件和.exe文件):[ ^ ]。



此项目是针对.NET 3.0编译的。



它演示了UserControl自身调整大小,因为底部的Panel在运行时可见或被用户隐藏。它演示了UserControl Panel可见性的控制,包括它所在的Form和来自 in UserControl的内容。



它还演示了考虑到需要在更改时调整UserControl,以便考虑UserControl的填充因子,并且UserControl保持一致的虚拟边框。



如果我对你的目标的假设(在我对你的OP的评论中表达)是正确的,创建一个可折叠的UserControl(或Panel),其中一个ContainerControl可见或隐藏,UserControl / Panel调整自身以适应当前内容...是我经常做的事情。



imho,简单......一旦你完成了一次:)我一直想为CodeProject写这个,所以,这就是初稿。



不幸的是,WinForms中的UserControls和ContainerControls(如Panels)的AutoSize属性存在实际问题:一旦你有控件位于这些容器中Docked,你将在运行时遇到问题。如果您认为可以使用AutoSize,请忘记它。



唯一的选择我知道o f是本例中演示的类型。< br $> b $ b

节日快乐!



免责声明:此代码示例仅供教育使用;我没有承诺修复/改进/维护代码,因为它现在是。当然,我欢迎任何错误报告。在这一点上,这将变成CP文章或Tip / Trick,我将支持代码。
There's a complete working WinForms example of a Collapsible UserControl (source and .exe files) here: [^].

This Project is compiled against .NET 3.0.

It demonstrates the UserControl resizing itself as a Panel at the bottom is made visible, or hidden by the user at run-time. It demonstrates control of the UserControl Panel visibility both from the Form it is sited in, and from within the UserControl.

It also demonstrates taking into account the need to adjust the UserControl when it's changed so that the Padding factor of the UserControl is taken into account, and the UserControl maintains a consistent "virtual border."

If my assumptions about your goal (expressed in my comment to your OP) are correct, creating a collapsible UserControl (or Panel), where one ContainerControl is made visible, or is hidden, and the UserControl/Panel resizes itself to fit the current contents ... is something I have done frequently.

imho, easy ... once you've done it once :) I have been meaning to write this up for CodeProject, so, this is kind of the "first draft."

Unfortunately, there are real problems with the AutoSize Property of both UserControls and ContainerControls, like Panels, in WinForms: once you have Controls sited within these containers that are Docked, you are going to have problems at run-time. If you thought you could use AutoSize, forget it.

The only alternative I know of is the kind demonstrated in this example.

Happy Holidays !

Disclaimer: This code example is provided for educational purposes only; I make no commitment to fix/improve/maintain the code as it is now. Of course, I welcome any bug-reports. At the point this is turned into a CP article, or Tip/Trick, I will support the code.


什么可能使它成为问题?
And what could make it a problem?
Panel Footer = //...
//...
Footer.Visible = false; 





-SA


这篇关于用户控件的页脚面板可见C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆