有没有更好的方法来处理这些控件,似乎缺少FlowLayoutPanel. [英] Is there a better way to handle these controls, FlowLayoutPanel seems to be lacking.
问题描述
当前,我正在使用FlowLayoutPanel
来显示我的自定义控件,到目前为止,它一直运行良好,但是现在当我想根据每个用户请求更改控件的布局时,似乎缺少了.我一直在尝试找到一种方法来更改FlowLayoutPanel
的WrapContents
属性,以使用新属性重新应用面板的布局,但要保持不足.
Currently I am using a FlowLayoutPanel
to display my custom controls, it has worked well so far but now seems to be lacking when I want to change the layout of the controls per user requests. I have been trying to find a way to change the WrapContents
attribute of the FlowLayoutPanel
to re-apply the layout of the panel with the new attribute but keep falling short.
所以我想知道是否有完全不同的解决方案.
So I was wondering if there was a completely different solution.
我要向用户显示两种控件,横幅和指示器.每个横幅都有24-48个指示灯(它们代表配电板).我想以两种方式向用户显示这些控件.
I have two types of controls I want to display to the user, banners and indicators. For every banner there are 24-48 indicators along with it (They represent electrical boards). I want to display these controls to the user in two ways. First in one long list (which FlowLayoutPanel
did pretty well with WrapContents = false
) and second in columns of lists, one per banner (So each column would be headed by a banner with its indicators beneath.)
下面是FlowLayoutPanel
在此任务上的工作方式的图片.对于一个长列表的第一种方法,它很简单,只需设置WrapContents = false
,所有内容都将排列在一个不错的长列表中.我遇到的问题是第二种方法.更具体地说,使FlowLayoutPanel
可以在两种显示表单的方法之间切换.如将WrapContents
设置为true
所看到的,LayoutEngine
创建列,但是将它们溢出到下一列. (我从未尝试解决此问题,在FlowLayoutPanel
上设置WrapContents
之后,我仍然停留在如何重新应用布局的问题上)
Below is a picture of how FlowLayoutPanel
did at this task. For the first method of one long list it was simple, just set WrapContents = false
and everything would line up in one nice long list. The problem I was having was for the second method; more specifically getting the FlowLayoutPanel
to switch between the two methods of displaying the forms. As you can see with WrapContents
set to true
the LayoutEngine
creates columns, but overflows them to the next column. (I never tried to fix this, I am still stuck on how to reapply the layout after setting WrapContents
on a FlowLayoutPanel
)
所以我的问题是,我的问题是否有更好的解决方案?
So my question is, is there a better solution to my problem.
- 是否存在可以以上述两种方式显示控件的布局面板?
- 还可以根据用户要求轻松地在两者之间切换(通过复选框/按钮来重绘/重新布置控件)?
推荐答案
是否存在可以以上述两种方式显示控件的布局面板?
Is there a layout panel that I can display my controls in the two manners described?
FlowLayoutPanel
是您要查找的面板,您遇到的问题是因为您的banner
和indicator
没有关联.因此FlowLayoutPanel
将它们中的每一个都当作一个单独的控件,因此您观察到的溢出.
FlowLayoutPanel
is the panel you are looking for, the problem you have is because your banner
and indicator
are not associated. so FlowLayoutPanel
treat each of them as an individual control, hence the overflow you have observed.
正如我在评论中指出的那样,您需要一个额外的用户控件来组合Banner
及其所有可能的Indicators
,并将此新控件添加到FlowLayoutPanel
中.
As I pointed out in my comments, you need an extra user control to combine Banner
and all its possible Indicators
, and add this new control into the FlowLayoutPanel
instead.
还可以根据用户要求轻松地在两者之间切换(通过复选框/按钮来重绘/重新布置控件)?
Also, easily switch between the two at the users request (by means of a checkbox/button that would redraw/relayout the controls)?
完成第一部分后,可以通过将FlowLayoutPanel
的FlowDirection
设置为TopDown
或LeftToRight
(将WrapContents
设置为False
)来切换布局.
When you done the first part, you can then switch layout by setting FlowLayoutPanel
's FlowDirection
to TopDown
or LeftToRight
(with WrapContents
set as False
).
这篇关于有没有更好的方法来处理这些控件,似乎缺少FlowLayoutPanel.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!