在DatagridViw事件下双击CellClick事件;
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
//获取行列索引
int row = dataGridView1.CurrentCell.RowIndex + 1;
int col = dataGridView1.CurrentCell.ColumnIndex + 1;
//获取单元格内容
string cell = dataGridView1.CurrentCell.Value.ToString();
MessageBox.Show("你点击的是第" + row.ToString() + "行,第" + col.ToString() + "列\n内容为:"+cell);
}
原文地址:https://www.cnblogs.com/zhongruanzikong/p/11818668.html
时间: 2024-11-11 05:15:24