Formatting multiple - selected cells

I am using a Grid Control and have set the property
this.gridControl1.AllowSelection = GridSelectionFlags.Any;

I am able to select multiple cells using the ctrl key but when I try to format all the selected cells, it is applied only to the last selected cell
Can you please tell how to implement a format change to all the selected cells..

thanks
Vivek

1 Reply

HA haneefm Syncfusion Team June 4, 2007 05:18 PM UTC

Hi Vivek,

You can hanlde the PrepareViewStyleInfo event to format the selected cells in a grid. Here is a code snippet that show this task:

private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
GridControl grid = sender as GridControl;
if( grid.Model.Selections.Ranges.AnyRangeIntersects(GridRangeInfo.Cell(e.RowIndex,e.ColIndex))
|| ( grid.CurrentCell.RowIndex == e.RowIndex && grid.CurrentCell.ColIndex == e.ColIndex ) )
e.Style.TextColor = Color.YellowGreen;
}

Best regards,
Haneef

Loader.
Up arrow icon