Rowspan style in RadGrid view

4 posts, 0 answers
  1. Marco
    Marco avatar
    9 posts
    Member since:
    Oct 2018

    Posted 22 Oct 2018 Link to this post

    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 i 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
                            secondCell.Style.ForeColor = Color.Black
                            Prev = item
                            Exit For
                        End If
                    Prev = item
                End If
        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

  2. Hristo
    Hristo avatar
    1521 posts

    Posted 23 Oct 2018 Link to this post

    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:

    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.
  3. Akarsh
    Akarsh avatar
    4 posts
    Member since:
    Feb 2020

    Posted 25 Feb 2020 in reply to Hristo Link to this post

    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.



  4. Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    4086 posts

    Posted 27 Feb 2020 Link to this post

    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 : 

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

    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.
Back to Top