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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to determine the index of selected row in gridControl

Thread ID:





89466 Aug 25,2009 12:45 PM UTC Aug 26,2009 09:38 AM UTC WinForms 2
Tags: Tools
Asked On August 25, 2009 12:45 PM UTC

Hi, everyone

I'd like to know how can I change the background of selected row according to user selection (something else than grd_cellclick, of course) when he clicks on arrows button, for example.


Kathiresan M [Syncfusion]
Replied On August 26, 2009 09:09 AM UTC

Hi Allon,

You could make use of PrepareViewStyleInfo event for this as illustrated below.

/// Highlight the current row
private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
GridControlBase grid = gridControl1;
GridCurrentCell cc = gridControl1.CurrentCell;

// Highlight the current row with SystemColors.Highlight and bold font
if (e.RowIndex > grid.Model.Rows.HeaderCount && e.ColIndex > grid.Model.Cols.HeaderCount
&& cc.HasCurrentCellAt(e.RowIndex))
e.Style.Interior = new BrushInfo(SystemColors.Highlight);
e.Style.TextColor = SystemColors.HighlightText;
e.Style.Font.Bold = true;

Please look at the below sample that illustrates this better.


Please post Grid related queries in Grid Forums instead of Tools.Windows Forums. Thanks for the co-operation.


Replied On August 26, 2009 09:38 AM UTC

Thanks, Kathir.

It works great now. From now on I'll post these posts through grid essentials.



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon