HighlightCurrentColumnHeader doesn''t change on Selecting the Column Header

I''m using HighlightCurrentColumnHeader=true, so that when I click a cell in the body of the grid the corresponding header is highlighted. But when I click on the header of a column itself, the select the full columm, or if I select one of my subheaders, it seems that the CurrentCell stays at the cell it was before, and the column header that is highlighted doesn''t change, which is unintuitive. Anything I can do? Thanks in advance.

6 Replies

AD Administrator Syncfusion Team June 29, 2005 07:38 PM UTC

The reason the header highlight does not move is because the currentcell does not move. You can try moving the currentcell when you click a column header by handling the grid.Model.SelectionsChanged event.
this.gridDataBoundGrid1.Model.SelectionChanged += new GridSelectionChangedEventHandler(Model_SelectionChanged);


private void Model_SelectionChanged(object sender, GridSelectionChangedEventArgs e)
{
	if(e.Range.IsCols && e.Reason == GridSelectionReason.MouseDown)
	{
		GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
		cc.MoveTo(cc.RowIndex, e.Range.Left);
	}
}


JH John Hawksley June 30, 2005 03:02 PM UTC

This doesn''t work. In fact, it seems that CurrentCell does change, as it should (although it seems to change back later). But since it gets set to a header cell, it may be that it doesn''t work right. >The reason the header highlight does not move is because the currentcell does not move. > >You can try moving the currentcell when you click a column header by handling the grid.Model.SelectionsChanged event. >
>this.gridDataBoundGrid1.Model.SelectionChanged += new GridSelectionChangedEventHandler(Model_SelectionChanged);
>
>
>private void Model_SelectionChanged(object sender, GridSelectionChangedEventArgs e)
>{
>	if(e.Range.IsCols && e.Reason == GridSelectionReason.MouseDown)
>	{
>		GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
>		cc.MoveTo(cc.RowIndex, e.Range.Left);
>	}
>}
>


AD Administrator Syncfusion Team June 30, 2005 03:20 PM UTC

How do I see the problem you are having in this sample? http://www.syncfusion.com/Support/user/uploads/GDBG_HighlightCurrentColumnHeader_d4547f68.zip


JH John Hawksley June 30, 2005 05:20 PM UTC

Yours seems OK. My problem probably comes from the fact that am already using a model selection changed event: private void Model_SelectionChanging(object sender, GridSelectionChangingEventArgs e) { GridRangeInfo headerIntersect = e.Range.IntersectRange(GridRangeInfo.Rows(0,2)); if (headerIntersect.IsEmpty == false) { if (headerIntersect.Width > 1) { e.Cancel = true; } else { e.Range = e.Range.IntersectRange(GridRangeInfo.Rows(3, dataGrid.Model.RowCount)); } } } That code prevents selection of multiple columns, and makes it so that when one of the header rows is clicked, it only highlights the body rows and not the top two rows. Then I have: private void Model_SelectionChanged(object sender, GridSelectionChangedEventArgs e) { if(e.Range.UnionRange(GridRangeInfo.Cells(0, e.Range.Left, 3, e.Range.Right)).IsCols && e.Reason == GridSelectionReason.MouseDown) { GridCurrentCell cc = this.dataGrid.CurrentCell; cc.MoveTo(cc.RowIndex, e.Range.Left); } } I am using e.Range.UnionRange... in the if statement there, since because of the first event listener, the column will not be fully selected. But it seems as if that if statement never evaluates to true. Any ideas? Thanks for having a good support team :) >How do I see the problem you are having in this sample? > >http://www.syncfusion.com/Support/user/uploads/GDBG_HighlightCurrentColumnHeader_d4547f68.zip >


AD Administrator Syncfusion Team June 30, 2005 06:00 PM UTC

Try this code. private int clickCol = -1; private void Model_SelectionChanged(object sender, GridSelectionChangedEventArgs e) { if(clickCol > 0 && e.Reason == GridSelectionReason.MouseDown) { GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; cc.MoveTo(cc.RowIndex, clickCol); } } private void Model_SelectionChanging(object sender, GridSelectionChangingEventArgs e) { GridRangeInfo headerIntersect = e.Range.IntersectRange(GridRangeInfo.Rows(0,2)); if (headerIntersect.IsEmpty == false) { clickCol = e.Range.Left; if (headerIntersect.Width > 1) { e.Cancel = true; } else { e.Range = e.Range.IntersectRange(GridRangeInfo.Rows(3, this.gridDataBoundGrid1.Model.RowCount)); } } else clickCol = -1; }


JH John Hawksley June 30, 2005 06:28 PM UTC

Strangely enough, that works when a body cell is selected and I click on one of the top headers, but not if a body cell is selected and I click on the 2nd or 3rd header. And if any of the headers is selected and i click on another header, it doesn''t work. I will continue to look at it myself.

Loader.
Up arrow icon