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.

How to determine the index of selected row in gridControl

Thread ID:

Created:

Updated:

Platform:

Replies:

89466 Aug 25,2009 08:45 AM Aug 26,2009 05:38 AM Windows Forms 2
loading
Tags: Tools
Allon
Asked On August 25, 2009 08:45 AM

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.

Regards,
Allon

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

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.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=Highlight-772061934.zip

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


Thanks,
Kathir

Allon
Replied On August 26, 2009 05:38 AM

Thanks, Kathir.

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

Regards,
Allon

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.

;