List<string> strColor = new List<string>();
strColor.Add("#e67817");
strColor.Add("#449284");
strColor.Add("#974478");
strColor.Add("#996666");
strColor.Add("#ffcccc");
strColor.Add("#999999");
strColor.Add("#669966");
strColor.Add("#cccc99");
strColor.Add("#669999");
strColor.Add("#cc3366");

if (list.Count >0)
                     {

                 Button[] btn= new Button[list.Count];
btn[] = new Button(); for (int i = ; i < list.Count; i++)
{
btn[i] = new Button();
btn[i].Size = new Size(, );
//btn[i].Text = list[i].Text; 设置按钮的text
btn[i].ForeColor = Color.White;
btn[i].Font = new Font("Tahoma", , FontStyle.Bold); btn[i].BackColor = ColorTranslator.FromHtml(strColor[i]); if (i >= )
{
if (i % == )
{
btn[i].Top = btn[i - ].Top + btn[i - ].Height + ;
btn[i].Left = btn[].Left;
}
else {
btn[i].Top = btn[i - ].Top;
btn[i].Left = btn[i - ].Left+ btn[i - ].Width+; }
}
else {
btn[i].Top = ;
btn[i].Left = ;
}
btn[i].Visible = true;
btn[i].Click += new EventHandler(BtnClick);//点击按钮触发事件
this.Controls.Add(btn[i]);
}

效果图:

最新文章

  1. MySQL每天自动增加分区
  2. C# 实现软件的重启
  3. 网络存储技术(3) based on zt
  4. [原创]推荐一款强大的.NET程序内存分析工具.NET Memory Profiler
  5. Objective-C 高级编程:iOS与OS X多线程和内存管理
  6. 1.6建造者模式(生成器模式) Builder
  7. Android_Dialog
  8. Linux系统编程(35)—— socket编程之TCP服务器的并发处理
  9. Ecstore的微信账号绑定会员免登录
  10. bzoj1336: [Balkan2002]Alien最小圆覆盖
  11. python模块 ---logging模块
  12. docker工作流程
  13. Mybatis if test 中int判断非空的坑
  14. 瞎捣鼓的code highlight
  15. CentOS7.2重置root密码的处理方法
  16. 2019CVTE技术支持软件编程2
  17. webpack学习笔记(五)
  18. Android:layout属性大全
  19. 【python】pip安装报错UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode byte 0xc4 in position 7: ordinal not in range(128)
  20. ECLIPSE 导入外部文件或源码包

热门文章

  1. 感知机算法及BP神经网络
  2. 【SVN】彻底 svn 服务器上的 删除某一个文件或文件夹
  3. web开发的三层架构
  4. VBA 格式化excel数据表 (数据分列)
  5. protobuf ubuntu 18.04环境下安装
  6. 阶段5 3.微服务项目【学成在线】_day04 页面静态化_18-页面静态化-模板管理-GridFS研究-取文件
  7. Oracle关联删除的几种方式
  8. Python实现按照指定要求逆序输出一个数字的方法
  9. 【ARTS】01_28_左耳听风-201900520~201900526
  10. dlopen, dlsym今天才刚知道干什么用的,羞死人了