处理多个视图/选项卡式 GUI 元素的最佳方法是什么
我正在开发一个应用程序,该应用程序可以根据正在查看的对象向用户提供各种数据。 这些对象都具有相同的接口,只是具有超出曾经区分的扩展属性。
我正在寻找向用户显示依赖于类型的控件的“最佳”方法。 我想使用选项卡,但我坚持使用 .NET 2.0,据我所知,隐藏/显示选项卡的唯一方法是删除它们并重新添加它们。 这可能是最好的方法,但这会导致 GUI 组件闪烁、重新加载时在活动选项卡上保留选项卡等问题。
我可以为每个控件制作自定义控件,或者将它们全部加载并在必要时隐藏/显示(这我过去曾在项目上做过),或者处理并重新实例化它们......
为了最好地澄清,我会说代码优雅和程序效率之间最接近的平衡。
I'm working on an application that presents the user with varied data, depending on the object being viewed. The objects are all of the same interface just with extended properties beyond once distinguished.
I'm looking for the "best" way to display a type-dependent control to the user. I would like to use tabs but I'm stuck with .NET 2.0 and from what I can gather the only way to hide/show tabs are to remove them and re-add them. That might be the best way but that leads to issues regarding blinking of the GUI components, keeping tabs on the active tab when reloading, etc.
I could make custom controls for each and either have them all loaded and hide/show when necessary (which I have done in the past on projects), or dispose and re-instantiate them...
To clarify best, I would say the closest balance between code elegance and program efficiency.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经使用过并且非常幸运地加载了所有这些,然后显示/隐藏了所需的。
处理和重新实例化所有东西总是让事情变得非常混乱。
为了不让加载时间变得可怕,您可以在第一次使用时实例化它们。 就像是:
I have used and have had the best luck with loading them all and then showing/hiding the ones needed.
Disposing and re-instantiating everything always made things very messy.
In order to not have load time be horrible, you can instantiate them on first use. Something like:
您能否为每个对象创建一个面板,并使用一个字典将对象类型和面板关联起来?
您可以告诉面板如果尺寸相同则将其置于前面,或者将所有 Panels.Visible 设置为 false,然后将您需要的面板设置为 true。
Could you just create a panel for each object and have a dictionary associate the object type and the panel?
You could just tell the panel to bring to front if they are all the same size, or set all Panels.Visible to be false, and just set the one you need to be true.
我已将 DockPanel Suite 用于需要多个选项卡的应用程序。
它是一个开源项目,因此您可以根据需要实际修改代码。
该套件有很多功能,但是,如果您只能使用选项卡的话。
I have used DockPanel Suite for applications that require multiple tabs.
It is an open source project, so you can actually modify the code if you wish.
The Suite has many functions, however, if you can just use the Tabs.