.net 对接控件
我创建了一个 CustomControl 来显示信息标签,并且可以使用箭头按钮最小化/恢复:
>应该停靠在表单的顶部。
然后,以相同的形式,通常我有一个包含所有正常控件的中心面板,这里以黄色显示只是为了突出显示它。
最后,我有一个底部面板,其中包含表单上可用的所有命令/按钮。这是停靠在底部的。
问题是我不知道如何设置中心面板在折叠顶部面板时自动消耗可用空间。也就是说,不存在“中心”对接样式。
如果我将中间面板停靠在顶部,那么当我折叠顶部面板时,我会得到:
如果我将中间面板锚定到所有边缘,我得到:
如果我停靠中间面板以填充该区域,然后它会填充表单的所有客户区,而不管其他面板是否存在。
是的,我可以在顶部控件中创建一个事件来通知谁对尺寸更改感兴趣,但是..这是一个丑陋的解决方案,因为它不是自动的:在每种表单中,我都必须监听该事件并相应地调整中间面板的大小。
这个问题有优雅的解决方案吗?
I have created a CustomControl to show information labels and that can be minimized/restored with an arrow button:
It should be docked to the top of a form.
Then in the same form usually I have a center panel with all the normal controls, here it is showm in yellow just to highlight it.
Finally I have a bottom panel containing all the commands/buttons available on the form. This is docked to the bottom.
The problem is that I don't know how to set the center panel to automatically consume the available space when I collapse the top panel. That is, there's no a "Center" Docking style.
If I dock the middle panel to the top, then when I collapse the top one I get:
If I anchor the middle panel to all the edges, I get:
If I dock the middle panel to fill the area, then it fills all the client area of the form, regardless the existence of the other panels.
Yes I could create an event in the top control to notify who is interested about the size change but.. It's an ugly solution because it's not automatic: in every form I'll have to listen to the event and resize the middle panel accordingly.
Is there an elegant solution to this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(3)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
使用Split容器就可以解决这个问题。
拖动面板并将面板停靠属性置于顶部(其中有扩展器/折叠按钮)。
现在拖动一个拆分容器并将方向更改为水平。并将停靠样式更改为填充。
现在,在 splitcontainer 顶部面板中拖动自定义控件并将表单控件添加到底部分割面板中。
当您想隐藏自定义控件时,请在顶部面板上单击按钮中编写以下逻辑,
当自定义控件折叠时,底部控件将占据总空间
Using Split container will solve the problem.
Drag a Panel and make the panel dock property to top (which has ur expander/collapse button).
Now drag a split container and change the oreintation to horizontal.and change dockstyle to fill.
Now in the splitcontainer top panel drag ur custom control and add ur form controls to the bottom splitter panel.
When you want to hide the hide ur custom control write the following logic in button click on top panel
the bottom contorl will occupy the total space when custom control collapses