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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Highlighting Column/Row Headers

Thread ID:





17357 Aug 6,2004 01:03 PM UTC Aug 6,2004 03:32 PM UTC WinForms 3
Tags: GridControl
Akshay Arora
Asked On August 6, 2004 01:03 PM UTC

using GridControl I''m trying to figure out how to get the column/row headers to mark which cells are currenctly selected. I was hoping that there would be a property for this. I noticed in Designer, the Property section of the GridControl, it had a MarkRowHeader and a MarkColHeader property, but it''s set to true and it doesn''t highlight the selected row or column. I''ve come up with something, but it''s pretty slow. In the SelectionChanged event I change the background color of Row[0] and Col[0] to LightGray and then I go through the Selections property of the grid and change the appropriate column/row to a different color. This runs rather slow. I did it with BeginInit and EndInit and without to see the differences. Any suggestions?

Administrator [Syncfusion]
Replied On August 6, 2004 02:44 PM UTC

I think you can do this using these two events.
private void grid_CurrentCellMoved(object sender, GridCurrentCellMovedEventArgs e)
	GridCurrentCell cc = this.grid.CurrentCell;
	this.grid.RefreshRange(GridRangeInfo.Cell(0, cc.MoveFromColIndex));
	this.grid.RefreshRange(GridRangeInfo.Cell(0, cc.MoveToColIndex));
	this.grid.RefreshRange(GridRangeInfo.Cell(cc.MoveFromRowIndex, 0));
	this.grid.RefreshRange(GridRangeInfo.Cell(cc.MoveToRowIndex, 0));

private void grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
	GridCurrentCell cc = this.grid.CurrentCell;
	if((e.RowIndex == 0 && e.ColIndex == cc.ColIndex)
		|| (e.ColIndex == 0 && e.RowIndex == cc.RowIndex))
		e.Style.BackColor = mColor;

Akshay Arora
Replied On August 6, 2004 03:20 PM UTC

Hi, This works great if only a single cell is selected. Is there a way to do it for all selected cells? I thought about perhaps using grid.RefreshRange within the SelectionChanged event, but that starts to cause Exceptions within another event (Mouse event).

Akshay Arora
Replied On August 6, 2004 03:32 PM UTC

Hi again, I''ve actually been able to come up with a reasonable solution. For anyone else that might need this in the future:
private void HandleGridSelectionChanged( object sender, GridSelectionChangedEventArgs e ){
			if( sender is GridControl ){
				GridControl grid = (GridControl) sender;
				grid.RefreshRange( GridRangeInfo.Row( 0 ) );
				grid.RefreshRange( GridRangeInfo.Col( 0 ) );

private void HandleGridPrepareViewStyleInfo( object sender, GridPrepareViewStyleInfoEventArgs e ){
			GridControl grid = (GridControl) sender;
			for( int i = 0; i < grid.Selections.Ranges.Count; i++ ){
				GridRangeInfo gri = grid.Selections.Ranges[ i ];
				if( ( e.ColIndex >= gri.Left && e.ColIndex <= gri.Right && e.RowIndex == 0 ) ||
						( e.RowIndex >= gri.Top && e.RowIndex <= gri.Bottom && e.ColIndex == 0 ) ){
					e.Style.BackColor = Color.LightBlue;


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon