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.