Change backcolor to a row at runtime

Hi 
Who is possible to change the backcolor to a row a runtime ?
I need to underline with a different backcolor the row that are edited
THank you for your support

Franco

1 Reply

AR Arulpriya Ramalingam Syncfusion Team November 6, 2017 11:59 AM UTC

Hi Franco,   
  
Thanks for using Syncfusion products.   
  
In order to change the back color for the edited rows at runtime, the QueryCellStyleInfo event can be used. In that event, the BackColor property can be used to change the back color. Moreover, the SourceListListChangedCompleted event can be used to get the edited row index based on condition. We have created a simple sample as per your requirement. Please make use of the below code and sample,   
  
Code example   
  
//Event triggering   
this.gridGroupingControl1.QueryCellStyleInfo += GridGroupingControl1_QueryCellStyleInfo;   
this.gridGroupingControl1.SourceListListChangedCompleted += GridGroupingControl1_SourceListListChangedCompleted;   
   
bool isChanged = false;   
int index = 0;   
List<int> indices = new List<int>();   
//Event customization   
private void GridGroupingControl1_SourceListListChangedCompleted(object sender,TableListChangedEventArgs e)   
{   
    if (e.ListChangedType == ListChangedType.ItemChanged)   
    {   
        isChanged = true;   
        //To get the row index from the record index   
        index = e.NewIndex + this.gridGroupingControl1.TableControl.TopRowIndex;   
        if(!indices.Contains(index))   
        {   
            indices.Add(index);   
        }   
    }   
    else   
        isChanged = false;   
}   
   
//Event customization   
private void GridGroupingControl1_QueryCellStyleInfo(object sender,GridTableCellStyleInfoEventArgs e)   
{   
    if (e.TableCellIdentity.RowIndex == -1)   
        return;   
    if (isChanged && indices.Contains(e.TableCellIdentity.RowIndex))   
        e.Style.BackColor = Color.Aquamarine;   
}   
  
Note   
Moreover, you can set the different back color for rows based on conditions. Please refer to the below UG,   
   
  
Regards,   
Arulpriya  


Loader.
Up arrow icon