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

Show Highlighting of a row when selected

Hi,

I have a grid control when a row is selected it just shows a border around the cell to show that it is selected. 

Is there a way to highlight the cell or change the forecolor of the row that is selected?

Thanks in advance.

1 Reply

AR Arulpriya Ramalingam Syncfusion Team July 28, 2017 01:16 PM UTC

Hi JeeNew, 
 
Thanks for your interest in Syncfusion products. 
 
Query 
Response 
I have a grid control when a row is selected it just shows a border around the cell to show that it is selected.  
 
Is there a way to highlight the cell or change the forecolor of the row that is selected? 
Suggestion 1 
 
In order to highlight the forecolor and back ground color of a selected row, the SelectionChanged and QueryCellInfo events can be used. In SelectionChanged event, the Range property can be used to find the selected range. In QueryCellInfo event, the TextColor property can be used to change the forecolor and the BackColor property can be used to change the back ground color of the selected row. Please make use of below code and sample, 
 
//Event Triggering 
this.gridControl1.SelectionChanged += GridControl1_SelectionChanged; 
GridRangeInfo selectedRange; 
//Event handling 
private void GridControl1_SelectionChanged(object sender, GridSelectionChangedEventArgs e) 
{ 
    selectedRange = e.Range; 
} 
 
//Event Triggering 
this.gridControl1.QueryCellInfo += GridControl1_QueryCellInfo; 
//Event customization 
private void GridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) 
{ 
    if (e.RowIndex > 0 && e.ColIndex > 0) 
    { 
        e.Style.CellValue = e.RowIndex * e.ColIndex; 
 
        if (selectedRange != null && selectedRange.Contains(GridRangeInfo.Cell(e.RowIndex, e.ColIndex))) 
        { 
      e.Style.TextColor = Color.Red; 
      e.Style.Font.Bold = true; 
      e.Style.BackColor = Color.AliceBlue;         
        } 
    } 
} 
 
Suggestion 2 
 
The PrepareViewStyleInfo event can also be used to highlight the selected row. Already we have provided a KB regarding the reported scenario. Please refer to the below KB link, 
 
 
 
Sample link: SelectionTextColor  
 
Regards, 
Arulpriya 


Loader.
Live Chat Icon For mobile
Up arrow icon