Highlighting Headers corresponding to the selection

Hello,

Posted on the forum a few years ago is this code:

private void HandleGridSelectionChanged(object sender, GridSelectionChangedEventArgs e)
{
if (sender is GridControl)
{
GridControl grid = (GridControl)sender;
grid.RefreshRange(GridRangeInfo.Row(0));
grid.RefreshRange(GridRangeInfo.Col(0));
}
}

private void HandleGridPrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
GridControl grid = (GridControl)sender;
for (int i = 0; i < grid.Selections.Ranges.Count; i++)
{
GridRangeInfo gri = grid.Selections.Ranges[i];
if ((e.ColIndex >= gri.Left && e.ColIndex <= gri.Right && e.RowIndex == 0) ||
(e.RowIndex >= gri.Top && e.RowIndex <= gri.Bottom && e.ColIndex == 0))
{
e.Style.BackColor = Color.LightBlue;
break;
}
}
}

The purpose of which is to highlight the column and row headers of the selected cells. This code works on a grid that does not have the Office2007 themes enabled but not if they are.

I'm using Office2007 themes in my grid, is it possible to set a property of the cell other than BackColor to highlight it when the theme is enabled?

Thanks,
Ben

1 Reply

MF Meera Fathima Syncfusion Team August 31, 2007 09:21 AM UTC


Hello Ben,

I am sorry about this delay in responding.

And regarding your query, it is not possible to change the back color of the cell(header/row) to highlight it while the grid control's GridVisualStyles property is set. Since while the GridVisualStyles is set, the appearance of the cell( header cell, button type cell etc., ) will get overridden and cannot be changed.

Please let me know if you have any questions.

Best Regards,
Meera.

Syncfusion, Inc.
http://www.syncfusion.com/

Loader.
Up arrow icon