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

Raising or Firing ExpandGroup Event Programmatically

1 Answer 133 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hector
Top achievements
Rank 1
Hector asked on 11 Nov 2011, 02:23 PM
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)
Me.rgvBids.GroupDescriptors.Add(groupingDescriptor)
  
Dim sortDescriptor As New tlrkDt.SortDescriptor
sortDescriptor.PropertyName = "Period"
Me.rgvBids.SortDescriptors.Add(sortDescriptor)

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,

Hector

1 Answer, 1 is accepted

Sort by
0
Accepted
Svett
Telerik team
answered on 15 Nov 2011, 09:33 AM
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:

C#:

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

VB.NET:
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,
Svett
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.

Tags
GridView
Asked by
Hector
Top achievements
Rank 1
Answers by
Svett
Telerik team
Share this question
or