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. A Case Study -- Performance Evaluation of a DRAM-Based Solid State Disk

    研究将固态硬盘作为持久存储层和传统硬盘的在数据库性能上的研究

  2. OS X平台上MySQL环境搭建

    参考资料: http://www.cnblogs.com/macro-cheng/archive/2011/10/25/mysql-001.html http://blog.csdn.net/just ...

  3. Entity Framework 插入数据 解决主键非自增问题

    http://blog.csdn.net/educast/article/details/8632806 与Entity Framework相伴的日子痛并快乐着.今天和大家分享一下一个快乐,两个痛苦. ...

  4. windows 系统下,小数据量Oracle用户物理备份

    环境:windows Server 2003 oracle 10g,系统间备份 目标系统创建共享文件,原系统挂载共享目录 写批处理脚本,用任务计划定时调用 Rem * 由于系统实时性要求不是很高,数据 ...

  5. Python多线程启动http.server

    OS: Windows 8.1 with update 关键字:Python3.4, http.server, Thread 例子代码如下: import os from threading impo ...

  6. hdu 2844 poj 1742 Coins

    hdu 2844 poj 1742 Coins 题目相同,但是时限不同,原本上面的多重背包我初始化为0,f[0] = 1;用位或进行优化,f[i]=1表示可以兑成i,0表示不能. 在poj上运行时间正 ...

  7. 创建第一个UI

    创建一个2D UI 制作UI时,首先要创建UI的"根".在Unity顶部NGUI菜单中选择Create,然后选择2D UI. 创建完成后,在Scene窗口中,NGUI自动生成了一个 ...

  8. CODEVS 1132 瑞士轮

    题目描述 Description 背景 在双人对决的竞技性比赛,如乒乓球.羽毛球.国际象棋中,最常见的赛制是淘汰赛和循环赛.前者的特点是比赛场数少,每场都紧张刺激,但偶然性较高.后者的特点是较为公平, ...

  9. java的装箱与拆箱

    在 JDK1.5 引入自动装箱和拆箱的机制后,包装类和基本类型之间的转换就更加轻松便利了.那什么是装箱和拆箱呢?我们分别来看下装箱:把基本类型转换成包装类,使其具有对象的性质,又可分为手动装箱和自动装 ...

  10. [CC150] Get all permutations of a string

    Problem: Compute all permutations of a string of unique characters. 此题用循环的方式不好做,下面是一种递归的思路: 把给的字符串看成 ...