點選DataGridView裡面的某一個單元格的事件
阿新 • • 發佈:2019-01-07
private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 2)
{
this.dataGridView2.Controls.Clear();
btnDetail.Bounds = this.dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
btnDetail.Visible = true;
btnDetail.Text = this.dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString();
btnDetail.Click += new EventHandler(btnDetail_Click);
this.dataGridView1.Controls.Add(btnDetail);
}
else
{
btnDetail.Visible = false;
}
}
{
if (e.ColumnIndex == 2)
{
this.dataGridView2.Controls.Clear();
btnDetail.Bounds = this.dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
btnDetail.Visible = true;
btnDetail.Text = this.dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString();
btnDetail.Click += new EventHandler(btnDetail_Click);
this.dataGridView1.Controls.Add(btnDetail);
}
else
{
btnDetail.Visible = false;
}
}