窗体内有一个 dataGridView1 控件,与数据库字段绑定可以正常显示数据。该控件的当前单元格可以用 dataGridViewX1.CurrentCell来表示。若dataGridViewX1.CurrentCell现在位于表格第一行的第三列,那它的左边一列或右边一列怎么来表示呢?谢谢!

解决方案 »

  1.   

    说法有误,我的意思是:
    若dataGridView1.CurrentCell现在位于表格第一行的第三列,那它的左边一列单元格或右边一列单元格怎么来表示呢?
      

  2.   

    CurrentCell不是有columnindex吗,左边就减1,右边就加1
      

  3.   

    楼上正解啊,ColumnIndex和RowIndex就是列索引和行索引。
    这个应该不难理解吧?
      

  4.   

    这样可以取左边一列单元格的值,也就是减1:
    dataGridView1[dataGridView1.CurrentCell.ColumnIndex-1,dataGridView1.CurrentCell.ColumnIndex].Value
    楼主问的是这个吗?
      

  5.   

    dataGridView1[dataGridView1.CurrentCell.ColumnIndex-1,dataGridView1.CurrentCell.RowIndex].ValueSorry,打错字了。