Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
410
WinGrid and XamGrid Group By - How to programmatically retrieve currently active grouping columns
posted

Hi,

We allow our users to select columns by which to group a grid. We need to save their choice so as to be able to re-instate it later (automatically).

Could you please let me know how to programmatically (C#) retrieve columns by which a grid is currently grouped, and also how to programmatically group a grid by some columns? We use WinForms UltraWinGrid and WPF XamGrid, and I would really appreciate if you could provide code samples for both of them.

 Thank you.

 Best regards,

Adam

Parents
  • 469350
    Offline posted

    Hi Adam,

    I don't know anything about the XamGrid. But for the WinForms grid, grouping is tightly tied to sorting. So what you do is loop through the SortedColumns collection on the band and check the IsGroupBy property on the column.

    To group a column, you use the SortedColumns.Add method. Use the overload that takes three parameters. The last param is a bool which indicates whether to group by the column.

Reply Children