Raising or Firing ExpandGroup Event Programmatically

2 posts, 1 answers
  1. Hector
    Hector avatar
    25 posts
    Member since:
    Jul 2011

    Posted 11 Nov 2011 Link to this post

    I have defined a group in a RadGridView using the following code:

    Dim groupingDescriptor As New tlrkDt.GroupDescriptor
    groupingDescriptor.GroupNames.Add("Period", System.ComponentModel.ListSortDirection.Ascending)
    Dim sortDescriptor As New tlrkDt.SortDescriptor
    sortDescriptor.PropertyName = "Period"

    The user is able to expand and collapse the group by clicking on the arrow just before the group header. However, the user has requested to be able to expand/collapse the group by clicking on the group header itself.

    How can I programmatically raise the event necessary for a RadGridView's group to expand and collapse when the user clicks on the header (not just the arrow)?

    Thanks in advance for any help you may provide,


  2. Answer
    Svett avatar
    728 posts

    Posted 15 Nov 2011 Link to this post

    Hi Hector,

    You can use the CellClick event of RadGridView to achieve the desired behavior. The following sample code snippet demonstrates how you can do it:


    private void radGridView1_CellClick(object sender, GridViewCellEventArgs e)
        GridGroupContentCellElement contentCell = sender as GridGroupContentCellElement;
        if (contentCell != null)
            contentCell.RowInfo.IsExpanded = !contentCell.RowInfo.IsExpanded;

    Private Sub radGridView1_CellClick(sender As Object, e As GridViewCellEventArgs)
        Dim contentCell As GridGroupContentCellElement = TryCast(sender, GridGroupContentCellElement)
        If contentCell IsNot Nothing Then
            contentCell.RowInfo.IsExpanded = Not contentCell.RowInfo.IsExpanded
        End If
    End Sub

    Best wishes,
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Back to Top