怎么做能带到以下效果:
单击DataGridView的一个单元格,返回此单元格所在行的某个单元格中的值?
例如;我单击DataGridView上的第3行第3列,DataGridView选中第3行,并且获取第3行中我想要的那个单元格中的值。
望多多指教,谢谢^_^

解决方案 »

  1.   

     string aa = this.dataGridView.Rows[3].Cells[3].Value.ToString();
      

  2.   

    楼上哥哥,应该是
    string aa = this.dataGridView.Rows[2].Cells[2].Value.ToString();
    吧?
    计数都是从0开始计的
      

  3.   

    选中指定行要设置属性:SelectionMode = FullRowSelect
    单击获取单元格的值:
    private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
    {
       object objCellValue = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
    }
      

  4.   

    你可以去msdn网站去.netframework类库中找到datagridview,这个控件,基本上就都知道了
      

  5.   

     if (dgv_EmpInfo.SelectedRows[0].Index>= 0)//判断是否选中
                {
                string str= this.dataGridView1.Rows[2].Cells[2].Value.ToString(); 
               }
      

  6.   


    写到datagridview的鼠标单击单元格内容事件CellContentClick里:
    label.Text = dataGridView.SelectedCells[0].Value.ToString();//获取鼠标点击的单元格,赋值给label,lz自己改为其他的
      

  7.   

    在 dataGridView的CellClick事件中
    string sp = zdwh.CurrentRow.Cells[3].Value.ToString();    //zdwh   datagridview名称这是我工作的时候用的方法,希望对你有用
      

  8.   

    dataGridView.CurrentRow.Cells[2].Value//当前选中行的第三个单元格的值
      

  9.   

    谢谢大家,我最后的结果是:
    object objCellValue = this.dataGridView1.Rows[e.RowIndex].Cells[0].Value;
    然后把objCellValue放到我需要的地方,进行转换就可以了。
      

  10.   

    谢谢大家,我最后的结果是:
    object objCellValue = this.dataGridView1.Rows[e.RowIndex].Cells[0].Value;
    然后把objCellValue放到我需要的地方,进行转换就可以了。
      

  11.   

    datagridview dtg=new datagridview();
    int aa=convert.toint32(dtg[dtg.currentcell.columnindex,dtg.currentcell.rowindex]);