Hi All:
How can I update a second column based on the value of the current cell in the AfterCellUpdate event of the UltraGrid?
Here's my code:
If e.Cell.Column.Key = "ZipCode" Then FoundZipRow = dtZips.Rows.Find(e.Cell.Text) If FoundZipRow IsNot Nothing Then 'Set the State column to FoundZipRow("State") Else 'Set the State Column to DBNull.value End If End If
Hi Mike:
Thanks for the update. That makes sense. I thought InitializeRow always fires, but it only looks like it fires if a change is made, which also makes sense.
I have the following code in my InitializeRow event:
''''''''''''''''''''''''''''''''''''''''''
'' Check to see if this is a blank row ''
e.Row.Cells.Count - 1
Then
BlankRow =
For
If
Next
InitializeRow will fire the first time the row is created - so it will fire before the user edits the cell. It wil also fire if the cell value changes when that cell does not have focus - so if the value of the cell in the data source changes rather than the value changing because the user changed it.
The InitializeRow is specifically designed for this sort of situation where you want to apply an appearance to a cell or row based on the value.
For sample code, I recommend that you check out the WinGrid Performance Guide. There's a section there on how to ues the InitializeRow event most efficiently.
Mike:
Can you send me a snippet of code how I would do that in the InitializeRow event?
Thanks for the feedback. Just curious. what's the advantage of doing it on the InitializeRow vs. AfterCellUpdate event? Just trying to get a handle on all of this....
I would recommend using InitalizeRow for this, rather than AfterCellUpdate.