How to click on group header bar to collapse expand?

3 posts, 1 answers
  1. Stanley
    Stanley avatar
    32 posts
    Member since:
    Apr 2012

    Posted 25 May 2012 Link to this post

    How to click on group header bar to collapse expand?

    Just to make more user friendly, let the user click on group header bar to collapse expand the list rather than click on the small button.

    Is possible?
    Please refer the picture from attachment.
  2. Answer
    Ivan Petrov
    Admin
    Ivan Petrov avatar
    707 posts

    Posted 30 May 2012 Link to this post

    Hello Stanley,

    Thank you for writing.

    You can achieve this behavior through the CellClick event. You have to check whether the user has clicked on a group row and collapse/expand the row. Here is a code snippet which demonstrates this:
    this.radGridView1.CellClick += new GridViewCellEventHandler(radGridView1_CellClick);
     
    void radGridView1_CellClick(object sender, GridViewCellEventArgs e)
    {
      if (e.Row is GridViewGroupRowInfo)
      {
        e.Row.IsExpanded = !e.Row.IsExpanded;
      }  
    }

    I hope this will be useful for you. Should you have further questions, I would be glad to help.
     
    All the best,
    Ivan Petrov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. Stanley
    Stanley avatar
    32 posts
    Member since:
    Apr 2012

    Posted 30 May 2012 Link to this post

    Thanks for help.

    The small icon cannot work properly, need to add in one more condition
    sender.GetType().ToString() == "Telerik.WinControls.UI.GridGroupContentCellElement")

    if (e.Row is GridViewGroupRowInfo &&
        sender.GetType().ToString() == "Telerik.WinControls.UI.GridGroupContentCellElement")
    {
        e.Row.IsExpanded = !e.Row.IsExpanded;
    }
Back to Top