Posted 22 July 2022, 1:45 am EST
Hi,
I created FlexGrid 3*5;
I want to merge cell in 1st and 2nd column,
but cells in 3rd column don’t.
Is there a way?
Forums Home / ComponentOne / WinUI Edition
Posted by: munemoto on 22 July 2022, 1:45 am EST
Posted 22 July 2022, 1:45 am EST
Hi,
I created FlexGrid 3*5;
I want to merge cell in 1st and 2nd column,
but cells in 3rd column don’t.
Is there a way?
Posted 25 July 2022, 1:27 pm EST
Hi Tugu,
I apologize for the delay.
You can implement this requirement by using setting FlexGrid’s AllowMerging property to Cells as follows:
flexGrid.AllowMerging = C1.WinUI.Grid.GridAllowMerging.Cells;
And then for enabling/disabling merging on columns you need to set the GridColumn’s AllowMerging property to true/false as per your requirement as follows:
flexGrid.Columns[0].AllowMerging = true;
flexGrid.Columns[1].AllowMerging = true;
flexGrid.Columns[2].AllowMerging = false;
I hope it helps
Best Regards,
Kartik
Posted 26 July 2022, 2:46 am EST
Thanks.
I 'll try it
Posted 1 August 2022, 2:38 am EST
Hello.
I was able to AutoMerge using this method. Thanks.
So,
Can I merge only within the same column and not merge cells side by side?
Posted 1 August 2022, 5:14 am EST
Hello Dolan,
The merging works both vertically and horizontally and it depends on your data.
By default, the cells get merged within the column and after that, if the adjacent rows are the same then it merges them also.
Please go through the CustomMerging project of the FlexGridExplorer product sample implementing the same.
…\Documents\ComponentOne Samples\WinUI\CS\Grid\FlexGridExplorer
If you have any specific use case then please share the screenshot explaining your requirement.
Regards,
Prabhat Sharma.
Posted 1 August 2022, 7:48 am EST - Updated 29 September 2022, 10:12 am EST
Hi Prabhat
Thank you for your reply.
if the adjacent rows are the same then it merges them also.
I do not want this behavior in your description.
(Yellow cells in the attached image do not need merging)
Regards,
Posted 2 August 2022, 12:42 am EST
Hello Dolan,
We are discussing this with the developers and will get back to you with the updates soon.
[Internal Tracking ID: C1XAML-30030]
Regards,
Prabhat Sharma.
Posted 2 August 2022, 2:06 am EST
Hi Prabhat
Understood.
Currently I work around it by inserting a column with Width=“0” AllowMerging=“False”.
Posted 2 August 2022, 12:07 pm EST
Hello,
For your requirement, you need to generate the custom MergerManager as given in the code snippet below and assign it to your grid:
private class VerticalMergeManager : GridMergeManager
{
public override GridCellRange GetMergedRange(GridCellType cellType, GridCellRange range)
{
if (cellType == GridCellType.Cell)
{
if (Grid.EditorRange != null && Grid.EditorRange.Contains(range))
{
return Grid.EditorRange;
}
if (AllowMerging == GridAllowMerging.Cells || AllowMerging == GridAllowMerging.All)
return GetMergedRange(Grid.Cells, new GridCellRange(0, 0, Grid.Cells.Rows.Count - 1, Grid.Cells.Columns.Count - 1), range, true, false);
}
return base.GetMergedRange(cellType, range);
}
}
grid.MergeManager = new VerticalMergeManager();
Please see if it helps!!
Regards,
Prabhat Sharma.
Posted 8 August 2022, 3:47 am EST
Hello,
I’m a little late to try it, but…
I was able to get the desired operation.
Thank you very much.