Trying to merge cells and it does not appear to be working
For atoz = 1 To arrChannel.Length - 2
For atoz2 = 2 To 10
Dim recordindex
recordindex = dgStockInfo.ResolveToRecordIndex(atoz)
Dim columnindex = dgStockInfo.ResolveToGridVisibleColumnIndex(atoz2)
Dim mappingname = dgStockInfo.Columns(columnindex).MappingName
Dim record = dgStockInfo.View.Records.GetItemAt(recordindex)
Dim cellvalue = dgStockInfo.View.GetPropertyAccessProvider().GetValue(record, mappingname)
If cellvalue = "" Then
dgStockInfo.AddRange(New Syncfusion.UI.Xaml.Grid.CoveredCellInfo(atoz2 - 1, 2, atoz, 1))
End If
Next
Next
dgStockInfo.GetVisualContainer().InvalidateMeasureInfo()
Thanks for your help,
Larry
Thank you for using Syncfusion Products.
We have analyzed your query “Merge cells is not working”. You can merge the range of empty cells in a row by setting the range in QueryCoveredRange which triggers in on-demand for each cell.
You can get the record, row and column index from GridQueryCoveredRangeEventArgs. You can use the GridQueryCoveredRangeEventArgs.Range property to merge the cells like in below code snippet.
|
dataGrid.QueryCoveredRange += dataGrid_QueryCoveredRange; void dataGrid _QueryCoveredRange(object sender, GridQueryCoveredRangeEventArgs e) { Dim mappingname = e.GridColumn.MappingName Dim record = e.Record Dim cellvalue = dgStockInfo.View.GetPropertyAccessProvider().GetValue(record, mappingname) If cellvalue = "" Then e.Range = New Syncfusion.UI.Xaml.Grid.CoveredCellInfo(e.RowColumnIndex.ColumnIndex - 1, 2, e.RowColumnIndex.RowIndex, 1)) End If |
Please refer the following UG link to know more about the merge cells in SfDataGrid:
http://help.syncfusion.com/wpf/sfdatagrid/merge-cells
Please let us know if this solution helps.
Regards,
Jayaleshwari N.
Can you set SelectionUnit as Cell to solve this problem. Merge cells are not supported when SelectionUnit is Row.
Thanks,
Sivakumar

We have prepared simple sample based on your requirement. Please find the sample and code snippet from below location.
Sample:
http://www.syncfusion.com/downloads/support/forum/123289/ze/GettingStarted-918618701
Code snippet:
|
this.dataGrid.QueryCoveredRange += DataGrid_QueryCoveredRange; IPropertyAccessProvider reflector = null; private void DataGrid_QueryCoveredRange(object sender, GridQueryCoveredRangeEventArgs e) { if (reflector == null) reflector = this.dataGrid.View.GetPropertyAccessProvider(); if (e.Record == null) return;
var colindex = this.dataGrid.Columns.IndexOf(e.GridColumn); if (colindex == this.dataGrid.Columns.Count - 1) return;
var val = reflector.GetValue(e.Record, dataGrid.Columns[colindex + 1].MappingName);
if (val == null || string.IsNullOrEmpty(val.ToString())) { e.Range = new CoveredCellInfo(e.RowColumnIndex.ColumnIndex, e.RowColumnIndex.ColumnIndex + 1, e.RowColumnIndex.RowIndex, e.RowColumnIndex.RowIndex); e.Handled = true; } |
Thanks,
Sivakumar
We are glad that your issue has been fixed.
Please let us know if you need any assistance.
Regards,
Ashwini P.
- 8 Replies
- 4 Participants
-
LM larry myers
- Mar 3, 2016 02:38 PM UTC
- Mar 7, 2016 12:00 PM UTC