Hi
I'm using the mergecell function of the WinGrid to merge cells in a single column where they have the same value, and it works great. However, I sometimes need to only merge cells based on the value of another column e.g. I have a table with three columns. I am merging the third column values across rows if they have the same value. However, I only want the merge to happen when the value in the first column also matches e.g.
Column A Column B Column CPencils Apples 1Pencils Pears 1---------------------------------Pens Bananas 1Pens Pineapples 1---------------------------------Pens Grapefruit 2
In the example above, the merge is occuring on Column C. Currently, the first four rows all get merged together, but I would like the merge to only occur on what is effectively the compound key of Columns A and C - so the first two rows should be merged, three and four should be merged, and the fifth should be on its own.
Can this be accomplished in the Grid?
Hi,
Yes, I beleive you can do this using the MergedCellEvaluator property on the column. What you do is create a class that implements IMergedCellEvaluator. This interface has only one method: ShouldCellsBeMerged. The method passes in two rows and the column being merged and you return true or false to indicate whether or not to merge the cells.
Perfect
Thanks a bunch Mike.