首页新闻找找看学习计划

动态生成控件,需要为控件添加click。但是出现了重复赋值的问题,求哪位前辈能够指点一下!

0
悬赏园豆:50 [已解决问题] 解决于 2017-10-10 08:25

 for (int i = 0; i < FtnList.BACHModuleList.Count; i++)
            {
                PictureBox pb = new PictureBox();
                Point pbLocation = new Point(HS + (i + 1) * 100 - 250, PicVS);
                pb.Width = 65;
                pb.Height = 65;
                pb.BackColor = Color.FromArgb(105, 164, 194);
                pb.Location = pbLocation;
                pb.Name = "pic" + FtnList.BACHModuleList[i].Name;
                pb.BackgroundImage = Properties.Resources.Arrow_Right;
                             
                pb.Click += pictureBox0_Click;//new System.EventHandler(pictureBox0_Click);                  
                    pb.Click += pictureBox1_Click;//new System.EventHandler(pictureBox1_Click);                                 
                this.Controls.Add(pb);

 

<hr/>              

<hr/>

<hr/>

  private void pictureBox0_Click(object sender, System.EventArgs e)
        {
           
        }

 

红线那段,究竟该怎么写?跪求指导!

 

水墨晨诗的主页 水墨晨诗 | 初学一级 | 园豆:111
提问于:2016-05-10 16:22
< >
分享
最佳答案
0

pb.Click += new System.EventHandler(pictureBox0_Click);                   
pb.Click += new System.EventHandler(pictureBox1_Click);             

收获园豆:50
刘宏玺 | 专家六级 |园豆:14004 | 2016-05-10 16:57
其他回答(1)
0

按你的 pb.Click 绑定,肯定是会触发两次,你说的重复赋值不知何意?

Yu | 园豆:12944 (专家六级) | 2016-05-11 11:40
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册