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. rpm的一些用法

    rpm2cpio *.rpm | cpio -imd     #解压一个rpm包 rpm -ivh *.rpm  --force         #强制安装这个rpm包 rpm -ivh *.rpm  ...

  2. Git-it:一个学习Git和Github的教程(软件)

    Git-it https://github.com/jlord/git-it 2016-08-01 在FreeCodeCamp的引导下了解到的Git-it.OSC有收录. Git-it是一个指导使用G ...

  3. linux RedHat6.4下nginx安装

    安装rpm 检测是否有已安装rpm包: rpm–qa | grep pcre rpm–qa | grep zlib rpm–qa | grep openssl 若没有则需安装(这些包可以在redhat ...

  4. jQuery队列控制方法详解queue()/dequeue()/clearQueue()

    queue(name,[callback]):  当只传入一个参数时, 它返回并指向第一个匹配元素的队列(将是一个函数数组,队列名默认是fx);$('#demo').queue('name') 当有两 ...

  5. 【原】yield的最基本用法

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Itca ...

  6. Android线程池的使用(未完)

    ExecutorService Executors public class Executors // 创建一个线程池,使用固定数量的线程操作共享无界队列. public static Executo ...

  7. DB天气app冲刺第二天

    烦躁 烦躁 很烦躁 从大早起就想做一个listview的列表 到晚上也没有做好.不知道为什么.决定明天去问问同学 .做不出来太影响心情了.虽然做出来东西的感觉是很好.. 另外觉得真的没有队友是挺孤独. ...

  8. 28 个必备的 Linux 命令行工具

    dstat & sar iostat, vmstat, ifstat and much more in one. slurm 网络流量图形化工具 vim & emacs 这个没人不知道 ...

  9. python中的reduce

    python中的reduce内建函数是一个二元操作函数,他用来将一个数据集合(链表,元组等)中的所有数据进行下列操作:用传给reduce中的函数 func()(必须是一个二元操作函数)先对集合中的第1 ...

  10. BZOJ 1596: [Usaco2008 Jan]电话网络

    Description Farmer John决定为他的所有奶牛都配备手机,以此鼓励她们互相交流.不过,为此FJ必须在奶牛们居住的N(1 <= N <= 10,000)块草地中选一些建上无 ...