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

HighlightCurrentColumnHeader doesn''t change on Selecting the Column Header

Thread ID:

Created:

Updated:

Platform:

Replies:

31075 Jun 29,2005 02:59 PM Jun 30,2005 02:28 PM Windows Forms 6
loading
Tags: GridControl
John Hawksley
Asked On June 29, 2005 02:59 PM

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.

Administrator [Syncfusion]
Replied On June 29, 2005 03:38 PM

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);
	}
}

John Hawksley
Replied On June 30, 2005 11:02 AM

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);
>	}
>}
>

Administrator [Syncfusion]
Replied On June 30, 2005 11:20 AM

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

John Hawksley
Replied On June 30, 2005 01:20 PM

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 >

Administrator [Syncfusion]
Replied On June 30, 2005 02:00 PM

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; }

John Hawksley
Replied On June 30, 2005 02:28 PM

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.

CONFIRMATION

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.

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.

;