Skip to content

Commit 02cf080

Browse files
ES-975464 - Resolve the ReadMe file length issue in this sample repository
1 parent d3c0cde commit 02cf080

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
1-
# Row-and-column-header-highlighting-based-on-selection-in-WPF-Grid-Control
2-
This sample shows row and column header highlighting based on selection in WPF Grid Control.
1+
# Row and column header highlighting based on selection in WPF GridControl
2+
3+
This sample shows row and column header highlighting based on selection in [WPF GridControl](https://help.syncfusion.com/wpf/gridcontrol/overview).
4+
5+
In Excel, whenever a selection is made, the headers of those rows and columns which are involved in the selection will be highlighted. You can get a similar behavior in the Grid by overriding the [OnPrepareRenderCell](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Controls.Grid.GridControlBase.html#Syncfusion_Windows_Controls_Grid_GridControlBase_OnPrepareRenderCell_Syncfusion_Windows_Controls_Grid_GridPrepareRenderCellEventArgs_) method.
6+
7+
`OnPrepareRenderCell` method will be invoked for every cell in the grid, when they are about to be rendered. Hence, using this method, the cells which are going to be rendered are identified and their headers are highlighted.
8+
9+
``` csharp
10+
class ExcelGrid : GridControl
11+
{
12+
protected override void OnPrepareRenderCell(GridPrepareRenderCellEventArgs e)
13+
{
14+
base.OnPrepareRenderCell(e);
15+
if (e.Cell.RowIndex == 0 && Model.SelectedRanges.AnyRangeIntersects(GridRangeInfo.Col(e.Cell.ColumnIndex)))
16+
{
17+
e.Style.Background = this.excelOrange;
18+
}
19+
else if (e.Cell.ColumnIndex == 0 && Model.SelectedRanges.AnyRangeIntersects(GridRangeInfo.Row(e.Cell.RowIndex)))
20+
{
21+
e.Style.Background = this.excelOrange;
22+
}
23+
}
24+
private Brush excelOrange = new SolidColorBrush(Color.FromRgb(244, 198, 111));
25+
}
26+
```

0 commit comments

Comments
 (0)