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.
Syncfusion Feedback

multiple header problem

Thread ID:

Created:

Updated:

Platform:

Replies:

59133 Apr 5,2007 06:31 AM Apr 11,2007 08:40 AM Windows Forms 4
loading
Tags: GridControl
Touqeer Ahmed Ahson
Asked On April 5, 2007 06:31 AM

Hello

I am trying to group multiple columns under a single column in grid. suppose I have two columns 'city' and 'country' and I made another column named 'address' as their header, by merging cells. so address column header have two children column headers, city and country.
now problem is whenever I click on the address column it just selects left most child column. I want to select all the columns that lies under the main column.

similarly when I click on any of child column header, it does not select its respective column, even though i have tried to set its cellType, Header and ColumnheaderCell.

haneefm [Syncfusion]
Replied On April 5, 2007 02:55 PM

Hi Touqeer,

This can be achieved by handling the CellClick event of the grid and use Model.Selection property to add the selection in a grid. The following is the code snippet.

private void gridDataBoundGrid1_CellClick(object sender, GridCellClickEventArgs e)
{
if( e.RowIndex == 0 )
{
e.Cancel = true;
GridDataBoundGrid grid = sender as GridDataBoundGrid;
grid.Model.Selections.Clear(true);
GridRangeInfo info = grid.Model.CoveredRanges.FindRange(e.RowIndex,e.ColIndex);
grid.Model.Selections.Add(GridRangeInfo.Cols(info.Left,info.Right));
}
if( e.RowIndex == 1 )
{
e.Cancel = true;
GridDataBoundGrid grid = sender as GridDataBoundGrid;
grid.Model.Selections.Clear(true);
grid.Model.Selections.Add(GridRangeInfo.Cells(1,e.ColIndex,grid.Model.RowCount,e.ColIndex ));
}
}

Please refer to the attached sample for implementation.
GDBGMultiHeader.zip

Best regards,
Haneef

Touqeer Ahmed Ahson
Replied On April 9, 2007 01:36 AM

Hi Haneef
it is working, thanks for help...
but there is a problem in it.
sub column header i.e first name and last name is not dragged properly as main column headers....

haneefm [Syncfusion]
Replied On April 9, 2007 07:07 AM

Hi Touqeer,

One way you can do this by derving the GridDragSelectMouseController class and overide HitTest. There you can adjust the return value so it is GridHitTestContext.SelectedRange if you are over row 1(sub column header) and row 0 (covered column header). You would have to remove the old controller and register your derived one with code like:

IMouseController controller = this.gridDataBoundGrid1.MouseControllerDispatcher.Find("DragSelect");
this.gridDataBoundGrid1.MouseControllerDispatcher.Remove(controller);
this.gridDataBoundGrid1.MouseControllerDispatcher.Add(new MyGridDragSelectMouseController(this.gridDataBoundGrid1));

Best regards,
Haneef

Touqeer Ahmed Ahson
Replied On April 11, 2007 08:40 AM

Hi Haneef,
I would be greatful if you provide me example code, I have tried it but could not get it right.
so please plz plz help........
Regards,
Touqeer

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.

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

;