We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Highlight current row and column

I''m wondering what is the best way to highlight the current row and column to which the current single cell selection belongs. It would end up looking like a big "plus sign" with the intersection at the current cell. Note 1 - I''m hiding the row and column headers in my GridControl. Note 2 - My cells have different backgrounds, some white, some grey, so they would need to retain those when you move off that cell. Thanks!

1 Reply

AD Administrator Syncfusion Team July 15, 2004 06:04 PM UTC

Try handling these two events.
private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	if(cc.RowIndex == e.RowIndex && e.ColIndex > 0)
		e.Style.BackColor = Color.LightGoldenrodYellow;
	else if(cc.ColIndex == e.ColIndex && e.RowIndex > 0)
		e.Style.BackColor = Color.LightGoldenrodYellow;
}

private void gridControl1_CurrentCellMoved(object sender, GridCurrentCellMovedEventArgs e)
{
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	if(cc.MoveFromRowIndex != cc.MoveToRowIndex)
	{
		this.gridControl1.RefreshRange(GridRangeInfo.Row(cc.MoveToRowIndex), true);
		this.gridControl1.RefreshRange(GridRangeInfo.Row(cc.MoveFromRowIndex), true);
	}
	if(cc.MoveFromColIndex != cc.MoveToColIndex)
	{
		this.gridControl1.RefreshRange(GridRangeInfo.Col(cc.MoveToColIndex), true);
		this.gridControl1.RefreshRange(GridRangeInfo.Col(cc.MoveFromColIndex), true);
	}
}

Loader.
Live Chat Icon For mobile
Up arrow icon