Saturday, January 24, 2015

Telerik Winforms 2010 SP1 - RadGridView - Expand/Collapse Grouped Row with Single Click

Row grouping is supported by RadGridView. To expand/collapse a grouped row, user can double click the grouped row or single click the chevron icon chevron.
Sometimes you may want to expand/collapse a grouped row with a single click (just like Windows XP collapsible panel). To achieve this, here is the solution.
void radGridView_CellClick(object sender, GridViewCellEventArgs e)
{
 if (sender is Telerik.WinControls.UI.GridGroupExpanderCellElement)
  return;

 GridViewGroupRowInfo rowInfo = e.Row as GridViewGroupRowInfo;
 if (rowInfo == null)
  return;

 rowInfo.IsExpanded = !rowInfo.IsExpanded;
}

Pay attention to code in line 3 and 4, since RadGridView already handled single click event, in this event handler, we need to exclude it.


Create a Successful Online Store at Bigcommerce! Try it Free Now!

No comments:

Post a Comment