我创建了一个表,创建了一个数据视图,并对数据视图进行了排序。然后我用三行数据填充表格,一切都很好。然后,我更改了应该导致它重新排序的行之一中的字段(小时)之一,但它没有重新排序。它似乎只影响数据视图的最后一行。我尝试删除并重新应用排序条件,但没有成功。知道这里有什么吗?
Function CreateStoreHours() As DataTable
StoreHours.Columns.Add("Store", GetType(String))
StoreHours.Columns.Add("Hours", GetType(Double))
StoreHours.DefaultView.Sort = "Hours ASC"
dgvStoresHours.DataSource = StoreHours
End Function
'Here I popluated the grid with three records. All were sorted correctly.
For v = 0 To StoreHours.DefaultView.Count - 1
If row("Store") = StoreHours.DefaultView(v).Item("Store") Then
Match = True
StoreHours.DefaultView(v).Item("Hours") = StoreHours.DefaultView(v).Item("Hours") + row("Hours")
'The Hours field gets adjusted properly, but it gets moved to the last record even
' though it should be sorted as the second record of three. This is also where I tried
' the un-sort and re-sort with no luck.
Exit For
End If
Next