惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LINUX DO - 最新话题
T
Tor Project blog
G
GRAHAM CLULEY
S
Security Affairs
P
Palo Alto Networks Blog
TaoSecurity Blog
TaoSecurity Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
aimingoo的专栏
aimingoo的专栏
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 三生石上(FineUI控件)
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
A
About on SuperTechFans
Microsoft Azure Blog
Microsoft Azure Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
CERT Recently Published Vulnerability Notes
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
Check Point Blog
宝玉的分享
宝玉的分享
Forbes - Security
Forbes - Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Microsoft Security Blog
Microsoft Security Blog
Schneier on Security
Schneier on Security
The Last Watchdog
The Last Watchdog
T
The Blog of Author Tim Ferriss
S
SegmentFault 最新的问题
H
Heimdal Security Blog
Recorded Future
Recorded Future
L
LangChain Blog
WordPress大学
WordPress大学
Know Your Adversary
Know Your Adversary
C
Cyber Attacks, Cyber Crime and Cyber Security
V
Visual Studio Blog
B
Blog
H
Help Net Security
T
Tailwind CSS Blog
The Hacker News
The Hacker News
雷峰网
雷峰网
P
Proofpoint News Feed
博客园 - Franky
Attack and Defense Labs
Attack and Defense Labs
有赞技术团队
有赞技术团队
S
Schneier on Security
T
Troy Hunt's Blog
云风的 BLOG
云风的 BLOG
Hacker News - Newest:
Hacker News - Newest: "LLM"
Blog — PlanetScale
Blog — PlanetScale
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Proofpoint News Feed

博客园 - semye

input+select(multiple)实现下拉框输入值 简单的js分页脚本 - semye - 博客园 请问做个类似这样的网站多少钱 省份和城市 - semye - 博客园 客户端取用户控件中服务器控件的标识 VS2003调试很慢 enctype="multipart/form-data" 群发邮件太慢了! SQL SERVER “数组参数” WEB水晶报表部署笔记 写程序解智力题,help!!! 低级错误是怎样“炼”成的? SQL语句区分大小写问题 发送邮件 - semye - 博客园 JS事件大全 WinForm程序实现滚动字幕与背景音乐 公历转换为农历 简单水晶报表程序与安装部署文件制作 导数程序
WinForm动态添加控件及其事件
semye · 2007-04-04 · via 博客园 - semye

 1        private void PhotoForm_Load(object sender, System.EventArgs e)
 2        {
 3            this.LoadPhoto();
 4        }

 5        private void LoadPhoto()
 6        {
 7            int  i= 0;
 8            string url = this.GetUrl();
 9            string[] sFiles = System.IO.Directory.GetFiles(url+"\\images\\small\\","*.*");
10            for(i=0;i<sFiles.Length;i++)
11            {
12                this.ViewPhoto(i,sFiles[i].ToString());
13            }

14        }

15        /// <summary>
16        /// 取项目路径
17        /// </summary>
18        /// <returns></returns>

19        private string GetUrl()
20        {
21            string b = Application.StartupPath;
22            int i = b.LastIndexOf("\\");
23            b = b.Substring(0,i);
24            int j = b.LastIndexOf("\\");
25            b = b.Substring(0,j+1);
26            return b; 
27        }

28        /// <summary>
29        /// 加载图片控件
30        /// </summary>
31        /// <param name="i">图片序号</param>
32        /// <param name="filePath">文件名</param>

33        private void ViewPhoto(int i,string filePath)
34        {
35            string name="";
36            name = "image_"+i.ToString();
37            PictureBox pb = new PictureBox();
38            pb.Name = name;
39            pb.Image=System.Drawing.Image.FromFile(filePath);
40            //保存文件名
41            pb.Tag = filePath;
42            this.Controls.Add(pb);
43            pb.Width=128;
44            pb.Height =96;
45            pb.Location = new Point(x,y);
46            x=x+230;
47            if((i+1)%4==0 && i!=0)
48            {
49                x=100;
50                y=y+120;
51            }

52            //添加事件
53            pb.Click += new System.EventHandler(picture_Click);
54
55        }
    
56        private void picture_Click(object sender, System.EventArgs e)
57        {
58            PictureBox pb = (PictureBox)sender;
59            string name = pb.Name;
60            string path = pb.Tag.ToString();
61        }

62