Highlighting active row

Thread ID:

Created:

Updated:

Platform:

Replies:

I am using the following code to highlight the "current" row in the grid:
GridControlBase grid = SelectionGrid;
GridCurrentCell cc = SelectionGrid.CurrentCell;
if ( e.RowIndex > grid.Model.Rows.HeaderCount && e.ColIndex > grid.Model.Cols.HeaderCount && cc.HasCurrentCellAt( e.RowIndex )) {
e.Style.Font.Bold = true;
e.Style.BackColor = Color.LightSkyBlue;
// e.Style.BackColor = Color.FromKnownColor( System.Drawing.KnownColor.Highlight);
}
I have two issues: 1) I would like to use the System's Highlight color for the back color and Highlight and ForeColor to Highlight Text, but can't figure out how to change the text color and 2) when the user clicks on a cell, that cell's back color is different. How do I get it to look the same as the rest of the row?
I guess in general, is there a better way to implement a "row select" looking mode?
Jeff

To change the text color, use the e.Style.TextColor property.
If you do not want the currentcell to be editable, then the simplest way to make sure it is the same color as the rest of the row is to handle the CurrentCellActivating event, and in the handler set e.ColIndex = 0.
If you want the cell to be editable and show some same colors as the rest of the row, it is possible, but requires a little more work handling PrepareViewStyleInfo and specifically checking for the current cell.