本文介绍了检索DataGridView的单击的行号和列号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们要获取行和列索引号.在DataGridView中选择的行.我们使用的代码如下,它没有任何响应.请提出建议.
We want to get Row and column index no. for the selected row in DataGridView. The code we used is as below, which is responding nothing. Please suggest how to do this.
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
string cellText = DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
textBox1.Text = cellText;
}
推荐答案
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
string cellText = e.RowIndex.ToString()+","+e.ColumnIndex.ToString();
textBox1.Text = cellText;
}
这篇关于检索DataGridView的单击的行号和列号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!