FlexGrid Column Merging Problem

Posted by: grapecity on 7 June 2021, 3:20 am EST

    • Post Options:
    • Link

    Posted 7 June 2021, 3:20 am EST

    Dear Sir/Mam,

    Can you please guide me against the attached image to merge as per our requirement ?

    Actually We would like to merge Credit_Limit & Credit Days According to The Merged Scope of [Party Name] i.e. only if two rows, then two rows only to show even if repeated values comes in…

    Please help me to display the report in better format…

    Regards-

    Sanjeeb

  • Posted 7 June 2021, 7:58 am EST

    Hi Sanjeeb,

    use custom merging:

    Set the merge mode as shown below, then define each merged range yourself:

    c1FlexGrid.AllowMerging = AllowMergingEnum.Custom;
    c1FlexGrid.MergedRanges.Add ( c1FlexGrid.GetCellRange (topRow, leftCol, bottomRow, rightCol) );
    

    Beware: are the first three columns fixed? If no you will have to define merged ranges yourself now.

    Hope this helps

    Wolfgang

  • Posted 7 June 2021, 9:31 pm EST

    Dear Sir,

    Thankx for the reply.

    But there may be thousands of rows and more than 100 of columns in the report…

    1. How can be possible to handle all those by the method you suggested ?
    2. And We also need merged cells vertically top aligned ?

    Regards-

    Sanjeeb

  • Posted 8 June 2021, 12:35 am EST

    Hi Sanjeeb,

    You can use the method demonstrated in the product sample “CustomMerge4” located at C:\Users\username\Documents\ComponentOne Samples\WinForms\v4.5.2\FlexGrid\CS.

    You can extend the C1Flexgrid and then you can override both GetMergedRange and GetData, and have GetData provide your custom data while the grid is calculating the

    merged ranges.

    To set the text alignment to be vertically on top, you can either set the TextAlign property of the column or you will have to set the text-align of the cells of the range.

    Please refer to the sample attached and modify it according to your requirements.

    Regards.

    Avnish

    PS:

    Thank You Wolfgang for the help. Yes, merged ranges can also be manually added by going through the rows and checking for the required criteria.

    CustomMerge4_mod.zip

  • Posted 8 June 2021, 7:51 am EST

    Dear Avnish Sir,

    Thankx a lot for almost solved.

    But the CreditDays first row and second row still not merged as per requirement.

    I tried to find out the reason in your code snippet you provided but couldn’t…

    Can you please guide ?

    Regards-

    Sanjeeb

    but first row of Credit Limit

  • Posted 9 June 2021, 12:29 am EST

    Hi Sanjeeb,

    If you would look at the overridden GetData method, you would see that we are returning a combination of [ current cell contents + cell content of party name column], which means that if the cell has the same content in both the current and party name column then it will be merged.

    The second row is not merged because it does not have the same data as the first one if you put 0 in the credit days column of the second row it will also be merged.

    If you want to merge the cells irrespective of the content and only based on the content of the party name column then you can modify the GetData method to only return [party name] column content and the cells will be merged based on that only, the merged cell will show the data of the first cell in the merged range.

    Hope this helps.

    Regards.

    Avnish

  • Posted 10 June 2021, 4:01 am EST

    Thankx a lot sir,

    I got you point.

    Regards-

    Sanjeeb

Need extra support?

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

Learn More

Forum Channels