Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Group by in Datagrid View

i have a scenario where i have to group the PinCode by city name like one city can have many pincode.

I have to do this in winform in datagrid. How can i do this so in datagrid i can see the + and - on before city.

I thing it can be done by nested grid. please, help.


Column A | Column B | Column C

  • Country
    • Zip Code | 10,00 | 15,00
    • Zip Code | 10,00 | 15,00
  • Country
    • Zip Code | 10,00 | 15,00
    • Zip Code | 10,00 | 15,00

Thanks. Shivam

like image 426
Shivi Avatar asked Oct 25 '10 06:10

Shivi


2 Answers

Have you seen the OutlookGrid on CodeProject?

This looks like it will allow you to expand and collapse individual rows as well as control the sort order. Because it extends the built-in DataGridView control, it even supports data binding!

However, it appears that nested grouping is not currently implemented, although you could look into modifying the source code yourself to add that feature if you decided an alternate presentation of your data is not appropriate.

like image 179
Cody Gray Avatar answered Oct 16 '22 08:10

Cody Gray


The DataGridView control does not support expandable/collapsible rows or nested tables. You will have to use a third party control to achieve this.

Alternatively, have a look at this article, which details how to subclass the existing control. This solution does not support databinding, however, which may limit its usefulness.

like image 45
Bradley Smith Avatar answered Oct 16 '22 06:10

Bradley Smith