Hello,
I need to show hierarchical data in WinGrid. There is only one data set that contains parent and childs. For example:
Name: Banks
ID= 1
Parent= Null
Name : Bank 1
ID =2
Parent: 1
Name: Bank 2
ID: 3
Parent:1
Name: Bank 11
ID: 4
Parent: 2
As you can see the Bank 11 should come under Bank1 , and the bank 1 should be under Banks. But in the WinGrid the Bank1 will be a totally separate group.
I use Outlook Group, and it groups them fine. But I want the data to be like this:
Banks
Bank 1
Bank 11
Bank2
But in the WinGrid when I use outlook group by it is like:
Bank11
Which is not trully hierarchical. Is there a way to do that?
The hierarchy in the grid is determined by the data source, so this really depends on what kind of DataSource you are using.
What you are describing here is a recursive data source - a table with a relationship back to itself. So you could achieve what you want using a DataSet with a single table and a RelationShip defined between the ID and the Parent column in the table.
Then all you would have to do is use the InitializeRow event of the grid to hide rows in the root band whose Parent is not null.