C# 重新组织 FlowLayoutPanel 中的控件
是否可以允许 FlowLayoutPanel 内的控件可供用户拖动,以便可以重新组织它们。如果我有一个标签列表,我想拖动并移动它们,就像桌面上的图标一样。我想抓取标签 A 并将其放在标签 B 和 C 之间。
另一个选择是,如果有另一个容器控件允许这种开箱即用的操作,我可能更喜欢它而不是编写拖放操作FLP 的处理程序。
编辑:我正在使用WinForms。
Is it possible to allow the controls inside a FlowLayoutPanel to be user draggable so that they can be reorganized. If I have a list of labels, I would like to drag and move them around, much like the icons on your desktop. I would like to grab label A and put it in between label B and C.
Another option, is that if there is another container control that allows this out-of-the-box, I would probably prefer it to coding a drag and drop handler for the FLP.
EDIT: I'm using WinForms.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
FlowLayoutPanel.SetChildIndex()
通过代码对其中的控件重新排序。或者,您可以对项目控件使用一些拖放重新排序,并更改模板以对项目使用 flowlayoutpanel。这是一个关于 SO 的相关问题,它对包装面板执行相同的操作,但可能很容易适用于流程面板: WPF:通过拖放重新排序 WrapPanel 内容?
You can use
FlowLayoutPanel.SetChildIndex()
to reorder controls within it through code.Or, you can use some drag/drop reordering for an itemscontrol, and change the template to use a flowlayoutpanel for the items. Here's a related question on SO that does the same thing for a wrappanel, but would probably easily work for a flow panel: WPF : Reorder WrapPanel content via drag and drop?