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
You can set the cell like that:
e.Cell.Row.Cells("State").Value = FoundZipRow("State")
I would recommend using InitalizeRow for this, rather than AfterCellUpdate.
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.
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