111,129
社区成员
发帖
与我相关
我的任务
分享 int q = 0;
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
q++;
if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
{
int h1 = dataGridView1.Location.Y + dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Size.Height * (1 + e.RowIndex);
int w1 = dataGridView1.Location.X + dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Size.Width * (1 + e.ColumnIndex);
Panel p = new Panel();
p.Name = "p" + q.ToString();
p.Location = new System.Drawing.Point(w1, h1);
p.Size = new System.Drawing.Size(100, 100);
p.BackColor = Color.Black;
this.Controls.Add(p);
}
}