1
我創建了一個表,創建了一個數據視圖並對數據視圖排序。然後我用三行數據填充表格,一切都很好。然後,我在其中一個應該使其重新排序的行中更改了一個字段(小時數),但沒有重新排序。它似乎隻影響數據視圖的最後一行。我嘗試刪除並重新應用排序條件,但沒有運氣。任何想法是什麼在這裏?defaultview.sort忽略默認視圖中的最後一行
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