0

嘿伙计们,所以我正在尝试接收最后编辑的单元格的列/行但是当我使用以下代码时,我收到的是我接下来选择的单元格(通过单击),因为它是被选中的单元格.

有什么办法吗?也许我只是没有适合 dataGridView 的属性

private void dataGridView1_CellEndEdit_1(object sender, DataGridViewCellEventArgs e)
{
         int column = dataGridView1.SelectedCells[0].ColumnIndex;
         int row = dataGridView1.SelectedCells[0].RowIndex;
}
4

2 回答 2

1
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
    {
        int column = e.ColumnIndex;
        int row = e.RowIndex;
    }
于 2012-12-21T10:29:40.453 回答
1

DataGridViewCellEventArgs为与单元格和行操作相关的 DataGridView 事件提供数据。它公开了两个属性ColumnIndexRowIndex

int column = e.ColumnIndex;
int row = e.RowIndex;

更多:正如@Mr_Green 所指出的,e.ColumnIndex并且e.RowIndex-1用于ColumnHeader & RowHeader.

于 2012-12-21T10:29:48.580 回答