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.

Show Highlighting of a row when selected

Thread ID:

Created:

Updated:

Platform:

Replies:

131786 Jul 27,2017 01:33 AM Jul 28,2017 09:16 AM Windows Forms 1
loading
Tags: GridControl
JeeNew
Asked On July 27, 2017 01:33 AM

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.

Arulpriya Ramalingam [Syncfusion]
Replied On July 28, 2017 09:16 AM

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 


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.

;