Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
How to programmatically update an cell beside an editing cell
posted

Hi experts,

The problem is like this, i have a ultragrid bound to a data class. there are 3 columns A , B and C in this grid. Columns A and B are editable while C is readonly. there is a relationship between them C = A + B. So after user input new value into A or B, the column C need to be updated immdiately.

i had tried lots of methods like update data class or cell C UI in AfterCellUpdate event handler but failed, could any body give any hints? thanks.

xiaolong  

  • 469350
    Suggested Answer
    Offline posted


            private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
            {
                e.Row.Cells["C"].Value = (int)e.Row.GetCellValue("A") + (int)e.Row.GetCellValue("B");
            }

  • 2145
    Offline posted

    You could try using a formula field to do this, however Not sure why your Aftercellupdate would not work provided you are using .value or the setvalue function, unless you have told it to re-load the grid from your datasource after update but without changing your data source.

    The other thing to be aware of though setting the value triggers aftercellupdate event again, so you want to put a check in there so it does nothing if the current cell.column.key value is 'C'.