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.
Unfortunately, activation email could not send to your email. Please try again.

Capture cell value change and update another cells on same row

Thread ID:

Created:

Updated:

Platform:

Replies:

130093 Apr 20,2017 11:26 PM Apr 21,2017 08:28 AM Windows Forms 1
loading
Tags: GridGroupingControl
Michael K
Asked On April 20, 2017 11:26 PM

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

Mohanraj Gunasekaran [Syncfusion]
Replied On April 21, 2017 08:28 AM

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  
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;