Delphi应用程序中的框架行为问题
我有一个广泛使用框架的应用程序,需要根据当时处于活动状态的表单隐藏/显示某些按钮。 为了保持按钮整齐且组织得当,我将它们放在面板上,并根据每个表单的需要显示或隐藏面板。 我的问题是,当每个表单最初创建时,框架上的面板都是乱序的,即使我明确告诉他们要按哪个顺序排列。 隐藏并重新显示表单后,面板的顺序正确。 关于如何从一开始就让它们保持正确的顺序有什么建议吗?
I have an application that uses a frame extensively and needs to hide/show certain buttons depending on which form is active at the time. In order to keep the buttons neat and organized appropriately, I have put them on panels and show or hide the panels as needed for each form. My problem is when each form is initially created, the panels on the frame are out of order even though I am explicitly telling them which order to put themselves into. After I hide and re-show the form, the panels are in the correct order. Any suggestions on how to keep them in the proper order from the very beginning?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
不要给面板明确的位置,而是尝试让它们对齐。 它们往往比普通方式粘得更好,并且如果您调整表单大小,它们可以更好地调整大小。
Instead of giving the panels explicit positions, try giving them alignments. They tend to stick better than way, and they do a better job of resizing if you resize the form.
您还可以尝试使用 stackpanel(或者是 flowpanel?)作为面板的父级。 然后您将拥有可以操纵的订单而不是头寸。
You can also try using a stackpanel (or was it flowpanel?) as parent for the panels. Then you will have a order instead of a position to manipulate.
也许你可以看看 DevExpress LAyoutControl? 它可以帮助我们创建始终看起来不错的界面,无论我们是否显示或隐藏某些组/面板。 如果您愿意,它甚至允许运行时自定义界面!
Maybe you can have a look at the DevExpress LAyoutControl? It helps us creating interfaces that always look good, no matter if we show or hide certain groups / panels. It even allows for run-time customization of the interface, if you want that!
您可以尝试通过坐标来组织它们,即:设置顶部和左侧。 除非你的面板对齐,否则这总是有效的(但需要做很多工作)。
You may try to organize them by coordinates i.e.: setting Top and Left. Unless your panels are aligned, this will always work (but it takes bit lot of work).
我遇到了这个问题,我发现解决方案是在 FormCreate 中(或在框架的 CMShowingChanged 方法中)执行此操作:
按照您需要的顺序恢复 - 这似乎可以直观地整理顺序。
I had this problem and I found that the solution was to do this in FormCreate (or in a CMShowingChanged method of your frame):
Restore in the order that you need - this seemed to sort out the order visually.