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

Capture cell value change and update another cells on same row

Dear Sir :

Could you give the good example to show how to capture the cell value change event and then get the changed cell value to update the another cells value on the same row

Thanks

Michael

1 Reply

MG Mohanraj Gunasekaran Syncfusion Team April 21, 2017 12:28 PM UTC

Hi Michael, 

Thanks for using Syncfusion products. 

Query 
Solution 
Could you give the good example to show how to capture the cell value change event and then get the changed cell value to update the another cells value on the same row 
Solution 1 
In order to achieve your scenario, you can use the Record.GetValue and Record.SetValue method to get\set the cell value in RecordValueChanged event. Please refer to the below code example, 

Code example 
this.gridGroupingControl1.Table.RecordValueChanged += Table_RecordValueChanged; 
 
void Table_RecordValueChanged(object sender, RecordValueChangedEventArgs e) 
{ 
    if (e.Column == "Ship City") 
    { 
        Record record = e.Record; 
 
        //Get the record value of particular column. 
        string value = record.GetValue(e.Column).ToString(); 
 
        //Update the value of column. 
        record.SetValue("Ship Country", value); 
    } 
} 
Solution2 
If you want to update the cell value while editing, you can use the TableControlCurrentCellEditingComplete event. This event will be triggered when editing is completed in current cell. Please refer to the below code example 
 
Code example 
this.gridGroupingControl1.TableControlCurrentCellEditingComplete+= 
gridGroupingControl1_TableControlCurrentCellEditingComplete; 
 
void gridGroupingControl1_TableControlCurrentCellEditingComplete(object sender, GridTableControlEventArgs e) 
{ 
    int col = this.gridGroupingControl1.TableDescriptor.ColIndexToField(currentCell.ColIndex); 
    string currentColumn = this.gridGroupingControl1.TableDescriptor.Columns[col].Name; 
    if (currentColumn == "Ship City") 
    { 
        Record record = this.gridGroupingControl1.Table.CurrentRecord; 
        string value = record.GetValue(currentColumn).ToString(); 
        record.SetValue("Ship Country", value); 
    } 
}  

Sample link: GridGroupingControl 

Please refer the following UG link, 
 

Regards, 
Mohanraj G  
 


Loader.
Up arrow icon