Skip to content

Commit f7b2b05

Browse files
authored
Merge pull request #2 from SyncfusionExamples/ES-975464
ES-975464 - Resolve the ReadMe file length issue in this sample repository
2 parents a54192f + c3b0c56 commit f7b2b05

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,28 @@
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+
# How to Highlighting Row and Column Header Based on Selection in WPF GridControl?
2+
3+
This sample shows row and column header highlighting based on selection in [WPF GridControl](https://www.syncfusion.com/wpf-controls/excel-like-grid).
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+
```
27+
28+
![GridControl with Highlighting row and column header](RowAndColumnHeaderHighlighted.png)

RowAndColumnHeaderHighlighted.png

29.7 KB
Loading

0 commit comments

Comments
 (0)