We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Changeing data in the dataset directly

When changing the data in the DataTable that is bound to the GDBG, the data on the grid does not always refresh, even when executing a Refresh method. I have also invalidated the row manually prior to issuing the Refresh and that does not help either. A symptom seems to be that in the cell deactivated event, I can see the new value being inserted into the column, but after the row saves, the value displayed in the grid is what gets saved to the DataRow. Any clues? Thanks, Virgil

4 Replies

AD Administrator Syncfusion Team August 12, 2005 01:33 PM UTC

If a cell is actively being edited, then changing the data directly in the datasource will not affect this actively editing as the TextBox/COmbobox/??? will still have the values that were being edited. And when the user leaves the cell, this value will be used to update the grid/datasource stepping on the value previously set. If you do not want this behavior, and it is your code that is changing the data source, you can try calling grid.CurrentCell.CancelEdit before you make the change.

VI Virgil August 12, 2005 02:41 PM UTC

Hi Clay, Let me explain a little bit more about what I am doing. In the GDBG I have 2 values, one for quoted and one for actual. When the quoted value changes, the actual must also change by a like amount. For example: The quoted value is 5 and the actual value is 3. If I change the quoted to 10, then the actual has to increment by 5, becomming 8. The way I am doing this is to store off the original values in the CurrentCellActivated then in the CurrentCellDeactivated event (if it is the quoted value) get the DataRow associated with the grid row and modify the actual amout accordingly. I am modifying the datarow and not the grid because the logic for changing data is broken ito a separate busness module. This works well if I do not change the actual value first. That is, the grid refreshes properly. If, however, I change the actual value, never leave the row and simply tab to the quoted value and change it, the actual value does not change in the grid and when leaving the row the improper value gets saved to the DataRow. Below is an example of the process I am using. ------------------------------------------------------------ Grid_CurrentCellDeactivated event GridNeedsRefreshed = PurchasedPart.DataChanged(_ChangedColumnName, Row, _OriginalValue) If GridNeedsRefreshed Then _Grid.Refresh() End If ------------------------------------------------------------ PurchasedPart.DataChanged method Select Case ChangedColumnName Case ColumnNames.BaseQuoteData.QuotedQuantity Call WorkflowHelpers.SetActualValue(ChangedRow, ColumnNames.BaseQuoteData.QuotedQuantity, ColumnNames.BaseQuoteData.ActualQuantity, OriginalValue) Result = True ------------------------------------------------------------ Public Shared Sub SetActualValue(ByVal ChangedRow As DataRow, ByVal QuotedColumnName As String, ByVal ActualColumnName As String, ByVal OriginalValue As Double) Dim DiffDouble As Double DiffDouble = Math.Abs(ChangedRow(QuotedColumnName) - OriginalValue) If IsDBNull(ChangedRow(ActualColumnName)) Then ChangedRow(ActualColumnName) = 0.0 End If If OriginalValue < ChangedRow(QuotedColumnName) Then ChangedRow(ActualColumnName) += DiffDouble Else ChangedRow(ActualColumnName) -= DiffDouble End If End Sub

AD Administrator Syncfusion Team August 12, 2005 04:25 PM UTC

Try setting grid.Binder.DirectSaveCellInfo = true in Form.Load to see if that makes a difference.

VI Virgil August 12, 2005 05:03 PM UTC

The wonderful magical you comes through again! Thanks.

Live Chat Icon For mobile
Up arrow icon