This is a migrated thread and some comments may be shown as answers.

Rowspan style in RadGrid view

3 Answers 574 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 1
Marco asked on 22 Oct 2018, 12:36 PM

I've set the row span style, the selection is applied only for the single cell but I need it for the whole merged cell. I've added the code for your reference. Please check image & do the needful.

 

code :

MergeVertically(Me.rdgvRGrid, New Integer() {0, 1})

 

  Private Sub MergeVertically(radGridView As RadGridView, columnIndexes As Integer())
        Dim Prev As GridViewRowInfo = Nothing
        For Each item As GridViewRowInfo In radGridView.Rows
            If Prev IsNot Nothing Then
                Dim firstCellText As String = String.Empty
                Dim secondCellText As String = String.Empty

                For Each As Integer In columnIndexes
                    Dim firstCell As GridViewCellInfo = Prev.Cells(i)
                    Dim secondCell As GridViewCellInfo = item.Cells(i)

                    firstCellText = (If(firstCell IsNot Nothing AndAlso firstCell.Value IsNot Nothing, firstCell.Value.ToString(), String.Empty))
                    secondCellText = (If(secondCell IsNot Nothing AndAlso secondCell.Value IsNot Nothing, secondCell.Value.ToString(), String.Empty))

                    setCellBorders(firstCell, Color.FromArgb(209, 225, 245))
                    setCellBorders(secondCell, Color.FromArgb(209, 225, 245))

                    If firstCellText = secondCellText Then
                        firstCell.Style.BorderBottomColor = Color.White
                        secondCell.Style.BorderTopColor = Color.White
                        secondCell.Style.ForeColor = Color.Transparent
                    Else
                        secondCell.Style.ForeColor = Color.Black
                        Prev = item
                        Exit For
                    End If
                Next
            Else
                Prev = item
            End If
        Next
    End Sub

 

    Private Sub setCellBorders(cell As GridViewCellInfo, color As Color)
        cell.Style.CustomizeBorder = True
        cell.Style.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.FourBorders
        cell.Style.BorderLeftColor = color
        cell.Style.BorderRightColor = color
        cell.Style.BorderBottomColor = color
        If cell.Style.BorderTopColor <> Color.Transparent Then
            cell.Style.BorderTopColor = color
        End If
    End Sub

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 23 Oct 2018, 07:37 AM
Hi Marco,

Merging cells in RadGridView is not currently supported. The solution you currently using will merge the cell visually but it will not change how the selection and navigation are working internally. You can also check RadGridView Merge Cells KB for additional information and an example: https://www.telerik.com/support/kb/winforms/details/radgridview-merge-celss.

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Akarsh
Top achievements
Rank 1
answered on 25 Feb 2020, 10:49 AM

Hi Hristo,

I tried with the 3rd method (I.e., MergeVertically/MergeHorizantally) and facing below issues:

1.When it is sorted the cell merging is not happening properly.

2.Cell values are missing for some cells when it is sorted.

3.Not able to align the text into the cell when it is merged.

Thanks,

Akarsh

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 27 Feb 2020, 03:10 PM

Hello, Akarsh,

Since RadGridView doesn't support cells/rows merging, the referred KB article is intended to demonstrate a sample approach how to simulate such functionality with hiding the cells' borders as if the cells/rows are merged. The provided approach is applicable for the specified version in the KB article and it may not cover all possible cases for later versions of the Telerik UI for WinForms suite. 

MergeHorizontally method expects start/end ColumnIndex as input parameters and it controls how to simulate cells merging. In the SortChanged event it is specified which columns exactly to be unified. However, I have noticed that in the foreach loop the RadGridView.Rows collection is being iterated. However, it is necessary to use the ChildRows collection for the sorted scenario. I have replaced using the Rows collection with ChildRows and then the merging simulation seems to be correct:

 

 

Note that we have a feature request in our feedback portal by creating a public thread on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link : https://feedback.telerik.com/winforms/1371416-add-radgridview-introduce-merge-cells-rows-functionality 

I hope this information helps. If you need any further assistance please don't hesitate to contact me.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Marco
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Akarsh
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or