Active Row Indicator

Hi, I would like to be able to set up the grid so that in the first column of the grid a small triangle is shown if the currently selected cell is on that row. Excel does a similar thing but highlight the first column when a cell is selected on that row. I have "allow selection" set to none. Thanks.

1 Reply

AD Administrator Syncfusion Team December 2, 2004 08:37 AM UTC

Actually, I think Excel colors the headers instead of showing an icon. But you can do either, coloring is a simpler as you do not have to manage an icon and draw it. You can use these events to handle colring teh current header row/col.
private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	if((e.ColIndex == 0 && e.RowIndex == this.gridControl1.CurrentCell.RowIndex)
		|| (e.RowIndex == 0 && e.ColIndex == this.gridControl1.CurrentCell.ColIndex))
	{
		e.Style.BackColor = Color.Orange;
		e.Style.Themed = false; //so color works on themed headers
	}
}
private void gridControl1_CurrentCellMoved(object sender, GridCurrentCellMovedEventArgs e)
{
	this.gridControl1.RefreshRange(GridRangeInfo.Col(0));
	this.gridControl1.RefreshRange(GridRangeInfo.Row(0));
}
If you want to use an icon, instead of PrepareViewStyleInfo, you can handle the CellDrawn event. There if it is a current row header, draw your icon. You would still need the CurrentCellMoved event to force the headers to be redrawn.

Loader.
Up arrow icon