Merge Column Headers

Hi

I'm currently evaluating Essential Grid (and am very impressed! Looks like we'll replace our existing grid control)

I'm having trouble getting merged column headers to work. Have been using the following code:

'merge and centre the column headers
With Me.GridControl1
.Model.Options.MergeCellsMode = GridMergeCellsMode.MergeColumnsInRow

'specify no merging for Standard style
.BaseStylesMap("Standard").StyleInfo.MergeCell = GridMergeCellDirection.None

'specify merging for Column Headers style
.BaseStylesMap("Col Header").StyleInfo.MergeCell = GridMergeCellDirection.ColumnsInRow

End With

'After this, I load data from a DataTable using PopulateValues (this works fine with merging turned off)

However the merging code must fail somewhere because when it later gets to:
Me.GridControl1.ColWidths.ResizeToFit(GridRangeInfo.Cols(0, Me.GridControl1.ColCount - 1))

...I get a NullReferenceException. Not sure what exactly is raising that though! The grid shows no rows or columns after this.

Any ideas what's wrong here?

thanks

Richard

2 Replies

HA haneefm Syncfusion Team May 31, 2007 06:25 PM UTC

Hi Richard,

You can try enabling the GridMergeCellsMode.OnDemandCalculation flag in a MergeCellsMode property. Please try the suggestion and let me know if this helps.

Me.GridControl1.Model.Options.MergeCellsMode = Syncfusion.Windows.Forms.Grid.GridMergeCellsMode.OnDemandCalculation Or Syncfusion.Windows.Forms.Grid.GridMergeCellsMode.MergeColumnsInRow

Best regards,
Haneef


RB Richard Bysouth June 4, 2007 11:30 PM UTC

Haneef

Thanks very much - that works perfectly!

I noticed there was also a typo in my code - the style name should have been "Column Header", not "Col Header".

Richard

Loader.
Up arrow icon