中软自控

博客园 首页 新随笔 联系 订阅 管理

在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);
}

 

 

posted on 2019-11-08 10:40  王钰涵  阅读(153)  评论(0编辑  收藏  举报