Posted 7 September 2023, 4:20 am EST
Hello,
can you please let me know how to make the text Bold on the selected column in the flex grid? I am using version 6.0.
Thanks & Regards
Forums Home / ComponentOne / WPF Edition
Posted by: rambabu on 7 September 2023, 4:20 am EST
Posted 7 September 2023, 4:20 am EST
Hello,
can you please let me know how to make the text Bold on the selected column in the flex grid? I am using version 6.0.
Thanks & Regards
Posted 7 September 2023, 4:21 pm EST
Hi Rambabu,
You can override GridCellFactory’s PrepareCell method for the FlexGrid’s CursorCell as per your requirement. Here is the code snippet for the same:
public class UserCellFactory : GridCellFactory
{
public override void PrepareCell(GridCellType cellType, GridCellRange range, GridCellView cell, Thickness internalBorders)
{
base.PrepareCell(cellType, range, cell, internalBorders);
if(Grid.Selection!=null && cellType == GridCellType.ColumnHeader && range.Column == Grid.CursorRange.Column)
{
cell.FontWeight = FontWeights.Bold;
}
else
{
cell.FontWeight = FontWeights.Normal;
}
}
}
In addition to this, you have to refresh the grid whenever the cursor cell changes. Please see the following code:
grid.CursorChanged += (s, e) =>
{
grid.Refresh();
};
Kindly refer to the attached sample for full implementation. (See ColumnHeaderText.zip)
Thanks & Regards,
Aastha