For a FlowLayoutPanel, you don't need to specify a location since the controls are arranged for you. Just change "this" to the name of your FlowLayoutPanel:

for (int i = 0; i < 5; i++)
{
Button button = new Button();
button.Tag = i;
flowLayoutPanel1.Controls.Add(button);
} ////

Populating a FlowLayoutPanel with a large number of controls and painting thumbnails on demand

To improve the speed of populating the FlowLayoutPanel with your user controls, disable layout updating while you add the controls.

Immediately before your loop, call SuspendLayout() and then at the end call ResumeLayout(). Make sure to use a try-finally to guarantee the ResumeLayout() runs even if an exception occurs.


Add controls dynamically in flowlayoutpanel的更多相关文章

  1. Cannot add Controls from 64-bit Assemblies to the Toolbox or Use in Designers Within the Visual Studio IDE

    原文地址:https://support.microsoft.com/en-us/kb/963017 Source: Microsoft Support RAPID PUBLISHING RAPID ...

  2. (WPF) MVVM: 动态添加控件及绑定。

    比如需要显示一个键盘,里面有各个按键.实现的效果如下: 之前的思路,就是建立一个singleKey的控件,然后在后台用代码动态的添加到父控件里去, 再用代码在后台进行绑定. 这种实现方法并不是真正的M ...

  3. threejs path controls example html

    <!DOCTYPE html> <html lang="en"> <head> <title>three.js webgl - pa ...

  4. 测试 Components 与 Controls 的区别(嵌套在Panel上的Edit,依然是Form1的Component)

    本例效果图: 代码文件: unit Unit1; interface uses   Windows, Messages, SysUtils, Variants, Classes, Graphics, ...

  5. ASP.NET 生命周期(原文翻译)

    在网上看到这篇文章,老外写的,里面很多图片挺精致,顺带翻译过来给大家分享下,英语太次好多地方都翻不过来 ASP.NET application and page life cycle Download ...

  6. 实现过程全纪录——自己写一个“微信朋友圈”(包括移动端与PC端)

    一.朋友圈的基本单元--动态 首先定义一个自定义控件用来显示每条动态. 二.运行效果 三.核心解读 PushedMessage 有个PushIndex属性,表示发送消息的index,从0开始递增.每个 ...

  7. Game Development Patterns and Best Practices (John P. Doran / Matt Casanova 著)

    https://github.com/PacktPublishing/Game-Development-Patterns-and-Best-Practices https://github.com/m ...

  8. Wrapping calls to the Rational Functional Tester API——调用Rational Functional Tester封装的API

    转自:http://www.ibm.com/developerworks/lotus/library/rft-api/index.html The Rational GUI automation to ...

  9. web forms page和control的生命周期life cycle交互,以及page生命周期中每个event中需要做什么事情

    只有 page_load和page_init这些可以autoeventwireup RenderControl只提供override public override void RenderContro ...

随机推荐

  1. TweenMax动画库学习(三)

    目录               TweenMax动画库学习(一)            TweenMax动画库学习(二)            TweenMax动画库学习(三)           ...

  2. CSS3之渐变效果

    在css3出来之前,想要出现渐变效果必须就要制作一张图片.不过css3的出现使得渐变效果变得简单.由于不是所有的浏览器都支持css3,所以不是所有的浏览器都能够呈现出css3的效果出来.因此目前大部分 ...

  3. Newtonsoft.Json.dll解析json的dll文件使用

    要解析的json //解析前 //解析前 {,,,,,,,,,,},,,,,,,,,,,},,,,,,,,,,,,,,,,},,,,,,,,,},,,,,,,,,,,,},,,,,,,,,,,},,, ...

  4. 重新开始学习c#啦,希望能坚持下去!

    过了这么多年,还是感觉自己喜欢C#,喜欢编程,虽然自己什么技术也没有:做的项目也不算是项目:

  5. 为什么Laravel是最成功的PHP框架?

    Laravel 是一个有着美好前景的年轻框架,它的社区充满着活力,相关的文档和教程完整而清晰,并为快速.安全地开发现代应用程序提供了必要的功能.在近几年对PHP 框架流行度的统计中,Laravel始终 ...

  6. OSG Win7 + VS2015 编译

    1. 准备 建立目标树 OpenSceneGraph-VERSION (VERSION替换为版本号) OpenSceneGraph-VERSION\3rdParty (把依赖库放在此目录) http: ...

  7. Python Geospatial Development reading note(1)

    chapter 1, Summary: In this chapter, we briefly introduced the Python programming language and the m ...

  8. 【转载】Java 升级到jdk7后DbVisualizer 6 启动空指针的处理方案

    将JDK从6升级到了7(或从其他电脑移植DBV文件夹后),每当启动DbVisualizer 6的时候都会报空指针异常 在官网上找到了相关的方案,如下: In the DbVisualizer inst ...

  9. bp神经网络算法

    对于BP神经网络算法,由于之前一直没有应用到项目中,今日偶然之时 进行了学习, 这个算法的基本思路是这样的:不断地迭代优化网络权值,使得输入与输出之间的映射关系与所期望的映射关系一致,利用梯度下降的方 ...

  10. xml &amp; 符号表示方法,xml转义字符

    HTML,xml 中<, >,&等有特别含义,(前两个字符用于链接签,&用于转义),不能直接使用.使用这三个字符时,应使用他们的转义序列,如下所示: & 或 &am ...