检索DataGridView的单击的行号和列号 [英] Retrieving clicked row and column number for DataGridView

查看:110
本文介绍了检索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;
}

推荐答案

尝试一下:)
try this :)
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
   string cellText = e.RowIndex.ToString()+","+e.ColumnIndex.ToString();
   textBox1.Text = cellText;
}


它看起来像您在表单上有2个网格?
its just look like u have 2 grids on form ?


这篇关于检索DataGridView的单击的行号和列号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆