jwcoleman87
Well-known member
- Joined
- Oct 4, 2014
- Messages
- 124
- Programming Experience
- Beginner
I have sub GetOrders which will basically refresh my datasource for my datagridview. It does this by simply querying the database and setting the datasource equal to the results of that query.
This causes weirdness when I would like to do something like figure out which records are new and which are old. In my mind there should be one datasource and it should be modified to be made accurate to real time, (not completely switched to another "new" datasource). If this was done the way I feel like it should work in my mind there would be no problem detecting which records were new. Unfortunately this way of refreshing data in a dgv is the only way I've learned thus far.
I've thought about copying all of the contents of the dgv into a dataset object, and then copying the new datasource to a different dataset object, and then comparing the two, but this seems clumsy.
I've also though about just taking a snapshot of the contents of the OrderID column, but this seems clumsy as well because the datagridview itself is not queryable.
Anyone already had to do this have some good tips on making this happen?
Again I'm just trying to determine which rows are new, not if there are new rows at all.
This causes weirdness when I would like to do something like figure out which records are new and which are old. In my mind there should be one datasource and it should be modified to be made accurate to real time, (not completely switched to another "new" datasource). If this was done the way I feel like it should work in my mind there would be no problem detecting which records were new. Unfortunately this way of refreshing data in a dgv is the only way I've learned thus far.
I've thought about copying all of the contents of the dgv into a dataset object, and then copying the new datasource to a different dataset object, and then comparing the two, but this seems clumsy.
I've also though about just taking a snapshot of the contents of the OrderID column, but this seems clumsy as well because the datagridview itself is not queryable.
Anyone already had to do this have some good tips on making this happen?
Again I'm just trying to determine which rows are new, not if there are new rows at all.
Private Sub GetOrders() Using db As New ProductionDataModelDataContext db.DeferredLoadingEnabled = False If dgvOrderQueue.SelectedRows.Count = 0 Then Dim orderqueue = From t In db.TTPartOrders _ Join pi In db.TTPartInventories On t.PartNumber Equals pi.PartNumber _ Join sku In db.SKUs On pi.PartNumber Equals sku.ManufacturerPart Where t.Closed = False _ Select t.OrderID, t.UserID, t.PartNumber, sku.ProductType, sku.Description1, sku.StdCost, pi.Location dgvOrderQueue.DataSource = orderqueue dgvOrderQueue.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells) Else Dim selectedorder = dgvOrderQueue.SelectedRows(0).Index Dim count = dgvOrderQueue.Rows.Count Dim orderqueue = From t In db.TTPartOrders _ Join pi In db.TTPartInventories On t.PartNumber Equals pi.PartNumber _ Join sku In db.SKUs On pi.PartNumber Equals sku.ManufacturerPart Where t.Closed = False _ Select t.OrderID, t.UserID, t.PartNumber, sku.ProductType, sku.Description1, sku.StdCost, pi.Location dgvOrderQueue.DataSource = orderqueue dgvOrderQueue.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells) If dgvOrderQueue.Rows.Count < count Then Exit Sub Else Dim printer As New ZBPrinter("10.101.2.241", 9100) dgvOrderQueue.Rows(selectedorder).Selected = True End If End If End Using End Sub