We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Need to Merge columns in GridGroupControl (VB)

Hi Experts,
I've one GGC for which i want to merge some specific columns, please check following data that I am getting from Database.

I tried the documentation which is given for merging and i tried following code.

Private Sub TestSyncGrid_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        dgv.TableDescriptor.Appearance.AnyRecordFieldCell.MergeCell = dgv.TableDescriptor.Appearance.AnyRecordFieldCell.MergeCell = GridMergeCellDirection.Both
        dgv.TableModel.Options.MergeCellsMode = GridMergeCellsMode.OnDemandCalculation Or GridMergeCellsMode.MergeRowsInColumn
        dgv.TableModel.Options.MergeCellsLayout = Syncfusion.Windows.Forms.Grid.GridMergeCellsLayout.Grid

    End Sub

Basically I want it to be look like following screen

except itemname,itemamount and sizetype i want rest of the columns to be merged like MergeCellsInColumn

Please check the code and advice,
Thank You,
Dhairya Joshi

1 Reply

AR Arulpriya Ramalingam Syncfusion Team September 25, 2017 12:01 PM UTC

Hi Dhairya,   
Thanks for your interest in Syncfusion products.   
We could understand your scenario. In order to restrict the merging for a particular column, the MergeCellDirection of the column can be set to none by using the MergeCell property of GridStyleInfo. We have created a simple sample as per your scenario. Please make use of below code and sample,   
Code example:  
'To merge the cells   
Me.gridGroupingControl1.TableDescriptor.Appearance.AnyRecordFieldCell.MergeCell =GridMergeCellDirection.Both   
'To restric for particular column   
Me.gridGroupingControl1.TableDescriptor.Columns("ItemName").Appearance.AnyRecordFieldCell.MergeCell = GridMergeCellDirection.None   
Me.gridGroupingControl1.TableDescriptor.Columns("Item").Appearance.AnyRecordFieldCell.MergeCell =GridMergeCellDirection.None   
Me.gridGroupingControl1.TableModel.Options.MergeCellsMode =GridMergeCellsMode.OnDemandCalculation Or GridMergeCellsMode.MergeRowsInColumn   
Me.gridGroupingControl1.TableModel.Options.MergeCellsLayout = GridMergeCellsLayout.Grid   
'To align the cellvalue of merged cells at center   
Me.gridGroupingControl1.TableDescriptor.Appearance.AnyRecordFieldCell.VerticalAlignment =GridVerticalAlignment.Middle   
The merging can also be added to some specific columns by using the MergeCell property of GridStyleInfo and the MergeCellDirection can be set as both. Please refer to the below UG link,   
Code example  
'To merge the cells of a particular column   
Me.gridGroupingControl1.TableDescriptor.Columns("Name").Appearance.AnyRecordFieldCell.MergeCell = GridMergeCellDirection.Both   

Live Chat Icon For mobile
Up arrow icon