【问题标题】:Getting the correct Row Index after sorting data with the datagrid使用数据网格对数据进行排序后获取正确的行索引
【发布时间】:2017-01-30 05:16:36
【问题描述】:

每当我对数据网格进行排序时,行的索引仍然是数据网格中尚未排序时的索引。我将如何做到这一点,以便当我选择一行时,它会从新排序的数据网格中获取索引?

这是我目前拥有的:

    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

【问题讨论】:

    标签: vb.net visual-studio-2015 datagrid


    【解决方案1】:

    您可以随时向DataGridVew 添加一列。 通常作为第一列,命名为 xIDx 或类似名称。 读取单元格的值将带来正确的行索引。

    【讨论】:

      猜你喜欢
      • 2012-08-16
      • 2019-12-16
      • 2012-11-14
      • 2014-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-06
      • 1970-01-01
      相关资源
      最近更新 更多