DataGrid 排序后确定DataSet选定行
发布: 2008-6-26 22:13 | 作者: admin | 查看: 14次
问:DataGrid 排序后, DataSet 如何确定选定行?
DataGrid 的 Allow sort =true 时,当点击 DataGrid 的列标题后,即对 DataGrid 中的数据安所选列进行排序,但是其对应的 DataSet 却保持着原有排序,这样的话,在 DataGrid中选定一行是,所返回的当前行就无法同 DataSet 中的行相匹配,请问如何才能知道DataGrid的当前行在DataSet中为哪一行呢?
答:
dim dt As DataT
dim dt As DataTable
dim Bind As BindingManagerBase
Me.OleDbDataAdapter1.Fill(Me.DataSet11, "users")
dt = Me.DataSet11.Tables("users")
C1FlexGrid1.DataSource = dt
Bind = BindingContext(dt)
Dim dr As DataRowView = Bind.Current '当前行记录












