批量添加 PictureBox ,如何在click 或 mouseDown事件里取出该pictureBox的坐标?
for (int i = 0; i < project.GetLength(0); i++)
{
//生成列头上的图标控件
PictureBox onColumnPic = new PictureBox();
onColumnPic.Name = controlName + i;
onColumnPic.Image = global::GridClass.Properties.Resources.筛选下拉箭头图标;
onColumnPic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
dataGridViewPoint.X += Convert.ToInt16(project[i,3]);
onColumnPic.Location = dataGridViewPoint;
onColumnPic.Click += new System.EventHandler(this.pictureBox_Click);
onDGV.Controls.Add(onColumnPic);
}
private void pictureBox_Click(object sender, EventArgs e)
{
在这里有什么办法取出pictureBox坐标呢?
其实用pictureBox1.location.x 也可以取出,但我是批量添加的控件,怎么知道点的是哪个pictureBox呢?
}
------解决方案--------------------private void pictureBox_Click(object sender, EventArgs e)
{
((pictureBox)sender).location.x...
}