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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Can't merge cells in GridControl of MultiColumnComboBox

Thread ID:

Created:

Updated:

Platform:

Replies:

146073 Jul 18,2019 04:25 PM UTC Jul 22,2019 06:37 AM UTC WinForms 3
loading
Tags: MultiColumnComboBox
Peregrino
Asked On July 19, 2019 07:45 AM UTC


We are using a MultiColumnComboBox control and we would like to customize the grid to merge cells (see above screenshot). However, using the below code does not seem to work. The QueryCanMergeCells callback does not appear to even get called.


var grid = this.multiColumnComboBox1.ListBox.Grid; // Grid is SyncFusion.Windows.Forms.Grid.GridControl type

grid.QueryCellInfo += Grid_QueryCellInfo;
            
// Set MergeCells direction for the GridControl.
grid.TableStyle.MergeCell = GridMergeCellDirection.ColumnsInRow; // | GridMergeCellDirection.RowsInColumn;

// Set merge cells behavior for the Grid.
grid.Model.Options.MergeCellsMode = GridMergeCellsMode.OnDemandCalculation | GridMergeCellsMode.MergeColumnsInRow;
            
grid.Model.Options.MergeCellsLayout = GridMergeCellsLayout.Grid;

grid.QueryCanMergeCells += new GridQueryCanMergeCellsEventHandler(Grid_QueryCanMergeCells);


private void Grid_QueryCanMergeCells(object sender, GridQueryCanMergeCellsEventArgs e)
{
     // Checking whether it is already merged cells.
     if (!e.Result)
     {
          // Sets merging for two cells with different data.
          var cell1 = e.Style1.CellIdentity;
          var cell2 = e.Style2.CellIdentity;
          if (cell1.RowIndex == 1 && 1 == cell2.RowIndex && cell1.ColIndex == 1 & cell2.ColIndex == 2)
         {
                    e.Result = true;
                    e.Handled = true;
                    e.Style1.CellValue = "test";
         }
     }
}

Attached the sample solution for reference. Thank you in advance.

Attachment: SyncFusionDemo_f97e7981.zip

Arulpriya Ramalingam [Syncfusion]
Replied On July 19, 2019 12:52 PM UTC

Hi Peregrino, 
 
Thanks for using Syncfusion products. 
 
We have analyzed the provided sample and in which the MergeCell option of the cells were not updated for the each cells. In order to overcome this scenario, the QueryCellInfo event can be used to set the MergeCell style for each cells. We have modified the provided sample and please make use of the below code and sample, 
 
Code example 
 
private void Grid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) 
{ 
    //To set the merge cell for each cell. 
    e.Style.MergeCell = GridMergeCellDirection.ColumnsInRow; 
    if (e.ColIndex == 1 && e.RowIndex > 1) 
    { 
        //To change the cell type as CheckBox 
        e.Style.CheckBoxOptions = new GridCheckBoxCellInfo("true", "false", "", true); 
        e.Style.CellType = GridCellTypeName.CheckBox; 
    } 
} 
 

Regards, 
Arulpriya 


Peregrino
Replied On July 19, 2019 04:31 PM UTC

That worked. Thank you so much, Arulpriya!

Jagadeesan Pichaimuthu [Syncfusion]
Replied On July 22, 2019 06:37 AM UTC

Hi Peregrino, 
 
Thanks for the update. 
 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 
 
Regards, 
Jagadeesan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon