流布局面板中控件的重新排序 [英] Reordering of controls within a flow layout panel

查看:26
本文介绍了流布局面板中控件的重新排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 C# winform 应用程序中使用 flowlayoutPanel 时遇到问题.我基本上拥有的是一个包含 3 个部分的流布局面板.

I'm having trouble using the flowlayoutPanel in a C# winform application. What I basically have is a flow layout panel that has 3 sections.

第 1 部分是一组 2 个控件.. 两个下拉控件,它们始终处于相同的顺序,在所有实例中始终可见

Section #1 is a set of 2 controls .. two dropdown controls, they are always in the same order, always visible in all instances

第 2 部分是一组 5 个不同的控件......基于一系列因素,5 个控件中的一个是可见的,所有其他控件的可见属性都设置为 false

Section #2 is a set of 5 different controls ... based on a series of factors, 1 of the 5 controls is made visible, all others have the Visible propert set to false

第 3 部分是一组 3 个控件... 像第 1 部分一样,它们始终处于相同的顺序并且始终可见.

Section #3 is a set of 3 controls .. like Section #1 they are always in the same order and always visible.

所以这归结为第 2 部分是可变的,其他部分是静态的.

So what this boils down to is that Section #2 is variable, the others are static.

问题来自第 2 节...当我更改任何控件的可见性时,它们看起来都很好(IE...第 1 节然后第 2 节然后第 3 节)...除了当我设置组合框时控制可见......在那种情况下,只有在那种情况下......顺序变成(第1节然后第3节然后第2节)......我不知道什么会导致排序超出在这种情况下同步.

The problem comes with Section #2 ... when I change the visibility of any of the controls they appear just fine (I.E. ... Section 1 then Section 2 then Section 3) ... EXCEPT when I set the combobox control to be Visible .... in that case, and ONLY in that case .. the order becomes (Section 1 then Section 3 then Section 2) ... I can't figure out what would cause the ordering to be out of sync in just that case.

我在方法开始时所做的基本上是将所有控件设置为 Visible = false ...然后我设置 Section 1 Visible = true ... 然后循环遍历 Section 2 的条件并设置适当的控件 Visible =true 并最终设置第 3 节控件 Visible = true.

What I basically do at the beginning of my method is set ALL controls to Visible = false ... then I set Section 1 Visible = true ... then loop through the conditions of Section 2 and set the appropriate controls Visible = true and finally set Section 3 controls Visible = true.

有人对流布局面板控件排序有任何经验吗?我无法弄清楚 ComboBox 发生了什么.

Does anyone have any experience with the flow layout panel control ordering? I can't figure out what is happening for the ComboBox.

推荐答案

将另一个 flowlayoutpanel 放入第 2 部分,然后将第 2 部分控件放入其中是否更容易?这样,顶部面板中的可见控件永远不会改变,您无需担心订购问题.

Might it be easier to drop another flowlayoutpanel in for section 2, then drop your section 2 controls into that? That way, the visible controls in your top panel never change and you won't have to worry about ordering.

这篇关于流布局面板中控件的重新排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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