Vb.net 使用datagrid对数据进行排序后获取正确的行索引

Vb.net 使用datagrid对数据进行排序后获取正确的行索引,vb.net,visual-studio-2015,datagrid,Vb.net,Visual Studio 2015,Datagrid,每当我对datagrid排序时,该行的索引仍然是datagrid中尚未排序的索引。我如何使它在我选择一行时,能够从新排序的datagrid中获取索引 以下是我目前拥有的: Private Sub DataGridView_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView.CellClick selectedRow = DataGridView.CurrentCell.R

每当我对datagrid排序时,该行的索引仍然是datagrid中尚未排序的索引。我如何使它在我选择一行时,能够从新排序的datagrid中获取索引

以下是我目前拥有的:

    Private Sub DataGridView_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView.CellClick
    selectedRow = DataGridView.CurrentCell.RowIndex
    TextBox1.Text = X_SystemDataSet.Table(selectedRow).Column1
    TextBox2.Text = X_SystemDataSet.Table(selectedRow).Column2
    TextBox3.Text = X_SystemDataSet.Table(selectedRow).Column3
End Sub

您始终可以在
DataGridVew
中再添加一列。 通常作为第一列,命名为xIDx或类似。 读取单元格的值将得到正确的行索引