Suggestion 1
In order to highlight the forecolor and back ground color of a selected row, the SelectionChanged and QueryCellInfo events can be used. In SelectionChanged event, the Range property can be used to find the selected range. In QueryCellInfo event, the TextColor property can be used to change the forecolor and the BackColor property can be used to change the back ground color of the selected row. Please make use of below code and sample,
//Event Triggering
this.gridControl1.SelectionChanged += GridControl1_SelectionChanged;
GridRangeInfo selectedRange;
//Event handling
private void GridControl1_SelectionChanged(object sender, GridSelectionChangedEventArgs e)
{
selectedRange = e.Range;
}
//Event Triggering
this.gridControl1.QueryCellInfo += GridControl1_QueryCellInfo;
//Event customization
private void GridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if (e.RowIndex > 0 && e.ColIndex > 0)
{
e.Style.CellValue = e.RowIndex * e.ColIndex;
if (selectedRange != null && selectedRange.Contains(GridRangeInfo.Cell(e.RowIndex, e.ColIndex)))
{
e.Style.TextColor = Color.Red;
e.Style.Font.Bold = true;
e.Style.BackColor = Color.AliceBlue;
}
}
}
|