remove covered range

Hi

I'm just trying merge cell with QueryCoveredRange event shown in documentation using

Merging cells based on the content

https://help.syncfusion.com/windowsforms/grid-control/cell-merging

the problem is how can i remove covered range in sfdatagrid.

there is no problem at first time with below code, but data changing can cause out of index error or some can't merge.

DataTable dt = new DataTable();

dt.Columns.Add("col1", typeof(string));

dt.Columns.Add("col2", typeof(string));

dt.Columns.Add("col3", typeof(int));

dt.Columns.Add("col4", typeof(int));

dt.Columns.Add("col5", typeof(int));


List col1 = new List() { "123456789", "234567890" };

List col2 = new List() { "AG000001", "AB000001" };

var r = new Random();

foreach (var c1 in col1)

{

foreach (var c2 in col2)

{

int cnt = r.Next(3, 9);

for (int i = 1; i <= cnt; i++)

{

System.Data.DataRow dr = dt.NewRow();

dr["col1"] = c1;

dr["col2"] = c2;


dr["col3"] = i;

dr["col4"] = i + 1;

dr["col5"] = i + 2;

dt.Rows.Add(dr);

}

}

}


dgvUpdateResult.DataSource = null;

dgvUpdateResult.DataSource = dt;

dgvUpdateResult.Columns[0].CellStyle.Font.Orientation = 90;

dgvUpdateResult.Columns[0].CellStyle.Font.Bold = true;

dgvUpdateResult.Columns[0].CellStyle.HorizontalAlignment = HorizontalAlignment.Right;

dgvUpdateResult.Columns[1].CellStyle.Font.Orientation = 90;

dgvUpdateResult.Columns[1].CellStyle.Font.Bold = true;

dgvUpdateResult.Columns[1].CellStyle.HorizontalAlignment = HorizontalAlignment.Right;

dgvUpdateResult.Columns[2].CellStyle.Font.Bold = true;

dgvUpdateResult.Columns[2].CellStyle.TextColor = Color.Blue;

dgvUpdateResult.Columns[3].CellStyle.Font.Bold = true;

dgvUpdateResult.Columns[3].CellStyle.TextColor = Color.Orange;

dgvUpdateResult.Columns[4].CellStyle.Font.Bold = true;

dgvUpdateResult.Columns[4].CellStyle.TextColor = Color.Red;


dgvUpdateResult.Refresh();


1 Reply

DM Dhanasekar Mohanraj Syncfusion Team July 29, 2022 01:58 PM UTC

Hi Angus chao,

We have checked the reported issue on our end, and we regret to let you know that we are unable to reproduce the reported issue on our end. Here we have attached the tested sample please have a look at this. If you still facing the reported issue please share the below things,

  1. The entire code snippet that is related to SfDataGrid? 
  2. Describe the details of the exception and its stacktrace that takes place when the stated issue occurs.
  3. Please check the exception details in Output messages if stacktrace of exception is not available or thrown as popup.
  4. Modify the attached sample based on your scenario and Video illustration of the reported issue.

It will be helpful for us to check the cause of the issue and to provide a solution at the earliest. 


Regards,

Dhanasekar M.


Attachment: SfDataGridDemo_9764d1a9.zip

Loader.
Up arrow icon