There is no such thing like impossible in software development. Impossible just takes longer.

I've investigated the problem. If there is really need for Flow Layout, it can be done with a bit of work. Since FlowLayoutPanel lays out the controls without particularly thinking about the number of rows/columns, but rather on cumulative width/height, you may need to keep track of how many controls you've already added. First of all, set the autosize to false, then hook your own size management logic to the ControlAdded/ControlRemoved events. The idea is to set the width and height of the panel in such a way, that you'll get your desired number of 'columns' there

Dirty proof of concept:

privatevoid flowLayoutPanel1_ControlAdded(object sender,ControlEventArgs e){int count =this.flowLayoutPanel1.Controls.Count;if(count %4==0){this.flowLayoutPanel1.Height=this.flowLayoutPanel1.Height+70;}}

if the panel has initially width for 4 controls, it will generate row for new ones. ControlRemoved handler should check the same and decrease the panel height, or get all contained controls and place them again. You should think about it, it may not be the kind of thing you want. It depends on the usage scenarios. Will all the controls be of the same size? If not, you'd need more complicated logic.

But really, think about table layout - you can wrap it in a helper class or derive new control from it, where you'd resolve all the control placing logic. FlowLayout makes it easy to add and remove controls, but then the size management code goes in. TableLayout gives you a good mechanism for rows and columns, managing width and height is easier, but you'd need more code to change the placement of all controls if you want to remove one from the form dynamically.

FlowLayoutPanel autowrapping doesn't work with autosize的更多相关文章

  1. How to get FlowLayoutPanel.AutoSize to work with FlowBreak

    have a problem with a FlowLayoutPanel and I don't know how to solve it. I'm placing two FlowLayoutPa ...

  2. C# Winform 通过FlowLayoutPanel及自定义的编辑控件,实现快速构建C/S版的编辑表单页面

    个人理解,开发应用程序的目的,不论是B/S或是C/S结构类型,无非就是实现可供用户进行查.增.改.删,其中查询用到最多,开发设计的场景也最为复杂,包括但不限于:表格记录查询.报表查询.导出文件查询等等 ...

  3. Winform 通过FlowLayoutPanel及自定义的编辑控件,实现快速构建C/S版的编辑表单页面 z

    http://www.cnblogs.com/zuowj/p/4504130.html 不论是B/S或是C/S结构类型,无非就是实现可供用户进行查.增.改.删,其中查询用到最多,开发设计的场景 也最为 ...

  4. [WinForm] TableLayoutPanel和FlowLayoutPanel的使用

    这篇文章主要跟大家分享下,在配餐系统的开发中,对tableLayoutPanel 和 flowLayoutPanel 控件的使用方法和技巧 ——后附上 测试demo, 相信需要的朋友下载看后能很快的知 ...

  5. FlowLayoutPanel

    动态生成控件  按顺序规律排列时 用panel的话 要指定特定的位置 .麻烦. 可以通过用flowLayoutPanel来解决. FlowLayoutPanel:表格布局面板,适合以表格形式规则的动态 ...

  6. WinForms中的Label的AutoSize属性

    当大量使用UserControl组合UI时,如果更改了Label的Text属性,Label.AutoSize属性会影响UserControl的OnLoad事件的发生顺序; public overrid ...

  7. Add controls dynamically in flowlayoutpanel

    For a FlowLayoutPanel, you don't need to specify a location since the controls are arranged for you. ...

  8. FlowLayoutPanel 内的控件怎么调换顺序?

    lowLayoutPanel1.Controls.SetChildIndex("flowLayoutPanel中的控件",顺序索引)

  9. 动态生成PictureBox控件,涉及:PictureBox控件和flowLayoutPanel面板

    一.概述 flowLayoutPanel面板是一系列控件的容器,有关详细的使用方法留待以后总结. 二.问题提出 问题提出:点击按钮,扫描指定文件夹并将其中的所有图片放在flowLayoutPanel面 ...

随机推荐

  1. C/C++代码检视要点

    4.1.1       C/C++代码检视要点 代码检视技能属于开发人员的基本功,能够很大程度地反应出开发人员的能力水平,前面4.4.1节已经讲过提高评审检视的方法.下面以实际的C/C++语言方面的代 ...

  2. 关于.NET技术前途问题的讨论

    我去年曾经在论坛发起过关于.NET技术前途问题这个话题的讨论,也引起了很多同行和朋友的回复,时间过去大半年,自己也有了一些新的理解.本文的目的就是将其中一些精彩的观点整理出来并谈谈自己的观点. 引子 ...

  3. 前端资源多个产品整站一键打包&包版本管理(一)

    来新公司工作的第五个月.整站资源打包管理也提上了日程. 问题: 首先.什么是整站的打包管理呢? 我们公司的几个重要产品都在同一个webapp里面,但是,不同的开发部门独立开发不同的产品,长期以来,我们 ...

  4. matlab2014在mac Yosemite下出现java空指针情况

    恢复方法为 使用xcode打开 /System/Library/CoreServices/SystemVersion.plist 将 ProductVersion 下的10.10或10.10.1改为1 ...

  5. 【10】了解Bootstrap栅格系统基础案例(5)

    这次我们来说下列排序: 通过使用 .col-md-push-* 和 .col-md-pull-* 类就可以很容易的改变列(column)的顺序. <!DOCTYPE html> <h ...

  6. 【3】Bootstrap的下载和目录结构

    [1]下载 去中方官网下载http://www.bootcss.com/ 如果你是做网页练习,你可以使用CDN加速服务,免去下载等痛苦,当然你使用的时候必须有连接上网络.中方的官网也提供了很多种类的C ...

  7. MaskedTextBox控件实现输入验证

    Mask属性可以验证用户在文本中输入数据的格式 this.maskedTextBox1.Mask = "000000-00000000-000A";//身份证号码18位 this. ...

  8. 【Git 】$ ./gradlew idea 构建一个idea的项目

    Welcome to Git (version 1.9.5-preview20150319) Run 'git help git' to display the help index.Run 'git ...

  9. MJRefreshFooterView

    实例化header和footer _header = [MJRefreshHeaderView header]; _header.scrollView = _tableView; 设置header和f ...

  10. JQ+AJAX实现多级联动

    利用JQ与AJAX实现三级联动实现的效果: 当前两级改变时,后边一级或两级都会改变: 使用的数据库: html代码: <!doctype html> <html lang=" ...