在点击事件中怎么得知被点击控件的索引?

ffb 2003-10-16 04:54:13
private PictureBox[] myPicQQ = new PictureBox[8];

...
this.Controls.Add(myPicQQ[i]);
this.myPicQQ[i].Click += new System.EventHandler(this.picQQ_Click);
...

private void picQQ_Click(object sender, System.EventArgs e)
{
...
这里我怎么得知点的是myPicQQ[?]
How can i get the index of myPicQQ ?
(which click??)
...
}
...全文
63 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ffb 2003-10-16
  • 打赏
  • 举报
回复
PictureBox box=(System.Windows.Forms.PictureBox)sender)
后box其实是myPicQQ[?]中的一员,可以得知自己在数组中的索引吗?
顾君彦 2003-10-16
  • 打赏
  • 举报
回复
((System.Windows.Forms.PictureBox)sender)
可以强制转换的,转换出来的就是点击的PictureBox,还要怎么样?
你找索引不也为了这个吗?
ffb 2003-10-16
  • 打赏
  • 举报
回复
我从sender只能得到下面的信息
sender:System.Windows.Forms.PictureBox, SizeMode: Normal
可以判断出点击的是什么控件,比如是text还是picture

但是我的picture是控件数组,我怎么得知点击的是数组中的哪个控件呢?
顾君彦 2003-10-16
  • 打赏
  • 举报
回复
see sender

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧