C1FlexGrid: Multiple rows and column merge is not working correctly?

Posted by: hdle on 27 February 2020, 8:09 pm EST

    • Post Options:
    • Link

    Posted 27 February 2020, 8:09 pm EST

    Hi,

    I can seem to get merge to work correctly across multiple rows and columns.

    The top image shows unmerged data and the bottom image is merge with:

    AllowMergingFixed = AllowMergingEnum.None;

    AllowMerging = true for all rows and columns.

    What am I missing?

    Thanks,

    HL

  • Posted 28 February 2020, 2:15 am EST

    Hi,

    You need to set the AllowMergingFixed property of the FlexGrid to AllowMergingEnum.FixedOnly to merge the Fixed cells and AllowMerging property accordingly to merge the normal cells.

    You can look at the sample name “CustomMerge2” in the product samples which shows how you can use built-in merging modes. The sample is located at: …\Documents\ComponentOne Samples\WinForms\v4.0\C1FlexGrid\CS\CustomMerge2



    Regards,

    Prabhat Sharma.

  • Posted 28 February 2020, 5:05 am EST

    Hi HL,

    Those “CustomMergeX” samples are a bit complicated ;-). The grid provides an easier way for this: You could also define custom merged ranges.

    To do so set this:

    this.c1FlexGrid.AllowMerging = AllowMergingEnum.Custom;
    

    Then you can add custom merged ranges with this code:

    this.c1FlexGrid.MergedRanges.Add(this.c1FlexGrid.GetCellRange(2, 2, 2, 4));
    

    Note: if your grid is refilled, you should clear the previously created merged ranges. Otherwise, the list would grow and grow.

    Best regards

    Wolfgang

  • Posted 28 February 2020, 12:34 pm EST

    Thank you all for your reply.

    Prabhat,

    .Free or .FixedOnly does not work when there are more than 2 rows to be merge. In my example, if I remove the top row, then it merge across correctly. It does merge correctly if the top row contain different text, but not when it is the same as the second rows. Can you check a 3 rows case like my sample?

    Wolfgang

    I tested the custom merge example that you had replied to someone else in the past, and that works fine. I was hoping that the merge flag would work correctly as intended (based on my assumption). Also, thanks for always helping out with this forum, I’ve been a long time user, and have seen your post since way back when.

    Thanks,

    HL

  • Posted 28 February 2020, 12:39 pm EST

    I forgot to mention that I am using version 4.0.20191.363

  • Posted 2 March 2020, 12:10 am EST

    Hi HL,

    I have modified that CustomMerge2 sample as per your comments but could not face any issue in merging, please see the attached GIF for reference.

    If you are doing something else then please let us know and modify the sample accordingly.

    Regards,

    Prabhat Sharma.

    CustomMerge2.zip

  • Posted 2 March 2020, 1:03 pm EST

    Hi Prabhat,

    I really appreciate your help looking into this. The key issue is if you have 4 adjacent cells with that same value, the merge free across row/col does not work as expected. Attached is a modified CustomMerge2 example (that you provided).

    CustomMerge3.zip

    In the screenshot below, I was expecting that the Merged cells would be merged, but it is not.

    It merges down but not across.

    Thanks,

    HL

  • Posted 3 March 2020, 2:25 am EST

    Hi HL,

    To achieve this output you need to look into the CustomMerge sample of the product samples achieving the desired result using custom merging logic. The sample is located at:

    …\Documents\ComponentOne Samples\WinForms\v4.0\C1FlexGrid\CS\CustomMerge

    I have modified the sample to achieve your desired output, please have a look.

    Regards,

    Prabhat Sharma.

    CustomMerge.zip

  • Posted 3 March 2020, 6:28 pm EST

    Prabhat,

    Your solution work exactly as I was expecting from the merge feature. I wonder why the default behavior is not like that.

    Thanks again!

    HL

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels