问题标签 [flowlayoutpanel]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
10113 浏览

resize - 无法在 FlowLayoutPanel 控件中调整子控件的大小

描述 我试图创建一个可以扩展的 FlowLayoutPanel,例如以水平方式。

FlowLayoutPanel 及其子组件锚点已设置为 Top-Left-Right

FlowLayoutPanel 方向已设置为 TopDown。

-> 当调整 FlowLayoutPanel 的大小时,它的子组件不会相应地调整大小。

重现步骤

  1. 在表单上创建一个 FlowLayoutPanel 控件。

  2. 将 FlowLayoutPanel 的 FlowDirection 设置为 TopDown。

  3. 创建一个 Button 控件,并将其放置在 FlowLayoutPanel 控件中。

  4. 选择 Button 和 FlowLayoutPanel 并将它们的 Anchor 设置为 Top-Left-Right

  5. 尝试以水平方式扩展 FlowLayoutPanel。

-> FlowLayoutPanel 已调整大小,但未调整 Button

0 投票
1 回答
6586 浏览

winforms - FlowLayoutPanel AutoSize 高度不起作用

我正在研究一个 UserControl,它由一堆 ComboBoxes 组成,这些 ComboBoxes 在 flowlayoutpanel 中的控件顶部水平排列,而在 flowlayoutpanel 正下方的 datagridview 占据了控件上的所有剩余空间。我需要能够轻松隐藏所有下拉列表,所以我有一个方向 == 水平的 SplitContainer,SplitContainer.Panel1 中有 flowlayoutpanel,SplitContainer.Panel2 中有 datagridview。

控制层次结构如下:

由于 flowlayoutpanel 是水平方向且水平空间有限,因此 flowlayoutpanel 的 WrapContents 属性为 True,因此当控件太窄而无法将所有下拉菜单放在一行中时,下拉菜单会向下换行。

我遇到的问题是,当 flowlayoutpanel 将其内容向下包装到下一行时,它的 Height 属性不会相应地改变。flowlayoutpanel 的包裹行被剪裁,并且不强制 splitcontainer 面板相应地增加高度。我尝试处理 FlowLayoutPanel.Resize 事件以增大和缩小 SPlitContainer.SplitterDistance 属性以适应包装的内容,但是包装内容时 FlowLayoutPanel.Height 属性不会改变。我难住了。FlowLayoutPanel 坏了吗?如果 FlowLayoutPanel.Height 始终保持不变,无论内容包装如何,我如何调整 FlowLayoutPanel 的父容器的大小?

谢谢

0 投票
2 回答
6905 浏览

.net - WinForms UserControl 布局自动调整大小问题

不久前,我发布了这个问题,关于尝试让 flowlayoutpanel 在停靠到容器顶部时正确自动调整大小。我试图完成的是设置一个跨越表单顶部边缘的水平(从左到右)flowlayoutpanel,并且一个datagridview占据了flowlayoutpanel下方的其余可用空间。我无法让 flowlayoutpanel 的 height 属性自动调整大小。发布的答案非常适合我想要完成的工作,这很棒......

无法独自离开,我现在正试图更进一步,将 flowlayoutpanel 包装在 UserControl 中。但是,我发现这样做会导致 flowlayoutpanel 不再正确调整其高度。

这是第一个布局,效果很好:

在这里,它使用了封装在 UserControl 中的 flowlayoutpanel:

无论出于何种原因,在调整表单大小时,flowlayoutpanel 都不会正确调整其高度。这很容易重现。哦,还有,FlowLayoutPanel 的内容可以是任何东西,而不仅仅是 ComboBoxes。

0 投票
2 回答
1671 浏览

c# - Unexpected index change when adding a control to a FlowLayoutPanel

I have a place in my code where I am dynamically adding controls to a Top-Down arranged FlowLayoutPanel. I need the controls to appear in a certain order so what I am doing everytime is clearing the FlowLayoutPanel.Controls collection and then adding each child control in the order I want them to appear. My code does this:

Most of the time this works great. However, there is one specific control that does not maintain it's position in the control collection when adding other controls after it. For instance in the following code segment:

This only happens the first time movingControl is added to Controls. If I go back and call arrangement1 and then arrangement2 a second time. The controls will appear the in intended order of:

  • control1
  • movingControl
  • control2
  • control3

This seems to be a bug in the code for Controls.Add. Either that or the documentation for .Add's behaviour is incomplete as it doesn't always add to the end of the collection. Does anyone have any insight into why this occurs. The obvious "fix" is to just call:

However, that seems like a very poor solution to some other underlying problem.

Thanks in advance for the help!

EDIT: Note that each of these controls is a member of a custom view class so they persist after the Controls collection is Cleared. However, these controls are not stored in any sort of ordered collection. They are just members of this custom class. The code shown above works correctly as shown. However, in the context of my GUI program it has the described erroneous behaviour. I would post more code if I had any idea what would be helpful but there is a lot of code that touches these peices. This is all of the code that executes for the described action.

What I'm really looking for is what possible scenarios cause a Controls.Add to Insert a control not at the last index of the collection. Specifically after a call to Clear() and with NO Remove() calls.

0 投票
2 回答
3177 浏览

c# - 拖动时如何滚动flowlayoutpanel?

在我的 Windows 窗体应用程序中,我使用 FlowLayoutPanel 控件向用户显示项目列表。通过让用户将控件拖动到 FlowLayoutPanel 中的所需位置,我已经能够成功地实现对 FlowLayoutPanel 中的项目的重新排序。

但是当用户将项目拖动到面板边界之外时,我不知道如何滚动 FlowLayoutPanel。我看过 ListView 控件的示例,但这些技术似乎不适用于 FlowLayoutPanel。

有人可以提供有关如何实现此功能的示例代码,最好是在 c# 中吗?

如果需要,我可以提供当前重新排序方法的代码示例。

谢谢!

0 投票
1 回答
2353 浏览

winforms - 嵌套的流程布局面板不换行

我有一个带有属性的 FlowLayoutPanel:

  • Dock = Fill(在用户控件中)
  • 流向 = 自上而下
  • WrapContents = 假

我这样做是为了让添加到面板的每个项目都添加到底部。

我添加到此面板的项目是用户控件,它们本身具有 FlowLayoutPanel,但是它们具有标准行为(LeftToRight,WrapContents = true)。我遇到的问题是内部用户控件的 FlowLayoutPanel 没有调整大小以填充外部控件,但是当我在这些控件上将 autosizing 设置为 true 时,面板不会包装其内容 - 这显然是一个已知问题.

如果它有助于可视化我正在尝试做的事情,它看起来像这样:

0 投票
2 回答
29549 浏览

wpf - FlowLayoutPanel 的 WPF 等效项是什么?

我正在开发一个 WPF 应用程序(一个名为“note your life”的笔记克隆),您可以在其中动态地将标签分配给一个条目(就像现在几乎所有的 web 2.0 应用程序一样)。为此,我在我的 Windows 表单原型中有一个 FlowLayoutPanel,它做得很好。如果没有足够的空间,我想让标签浮动到下一行,并在需要时获得一个滚动条。

如何使用 WPF 实现这一点?我玩过

但这不会在需要时移动下一行中的元素。

0 投票
1 回答
4352 浏览

.net - Flowlayout panel and autosizing child controls doesn't work

I am trying to get a very simple autosizing layout on a winform (C# .NET). I've tried TableLayoutPanels and FlowLayoutPanels but nothing works.

I have a usercontrol which is a container for other usercontrols which are created at runtime - I've called it StackPanel as I want it to list the child controls vertically. I've tried this using a FlowLayoutPanel, TableLayoutPanel and a Panel (with each control docked to the top).

The child usercontrol consists of a label and then any number of radiobuttons (or any other standard control - it doesn't matter).

When the child controls are created, the label text is set (if this is long it needs to wrap to a new line) and the radio buttons are added.

There seems to be no combination of docking/autosizing or manual size setting using the Resize events that can get everything to show without clipping and still resize with the form.

Thanks!

0 投票
5 回答
9196 浏览

c# - 在 FlowLayoutPanel 滚动期间,背景扭曲 + 闪烁

我有一个具有背景的 Windows 窗体应用程序。在其中,我有一个带有透明背景的 flowlayoutpanel。当我滚动时,会发生以下情况:

在此处输入图像描述

我也看到一些闪烁。我已经尝试了所有的双缓冲​​业务,但它不起作用。

有什么建议么?

0 投票
4 回答
17107 浏览

c# - 内部带有 flowlayout 面板和 autosize = true 的 Groupbox 像空的一样收缩

我有一个包含一个流程布局面板的组框,流程布局面板包含一堆控件。我将 flowlayout 面板设置为与父级对接。由于我不知道面板中有多少控件,所以我将分组框 autosize 设置为 true 并将 autosizemode 设置为增大和缩小。当我这样做时,组框会缩小,就好像它是空的一样。我需要标题,所以我不能删除组框。有谁知道为什么会这样?