Link to home
Start Free TrialLog in
Avatar of andre72
andre72

asked on

Add row headers to a DataGridView

Hi,

I've a simple DataTable like this:
ID | Name | isActiv

I create a DataView with and sort it by isActiv, Name .
Now I attach it as a DataSource to a DataGridView:
ID | Name | isActiv
1 | Andre1 | true
2 | Andre2 | true
3 | Andre3 | true
4 | Andre4 | true
5 | Andre1 | false
6 | Andre2 | false

This works fine but I like to give the active and also the none activ a row header like this:
Active ones
1 | Andre1 | true
2 | Andre2 | true
3 | Andre3 | true
4 | Andre4 | true
Inactive ones
5 | Andre1 | false
6 | Andre2 | false

The goal would be to let the groups expand / collapse on click but this is not necassary.
I know the great controls like eg. OutlookGrid and TreeDataGrid but I think there's no need to change my code to include such powerful controls for only insert two rows ...

Thanks

Andre
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

>but I think there's no need to change my code to include such powerful controls for only insert two rows ...

I think otherwise.

1) Either use one of those controls which supports grouping
or
2) Use a dataset, create two datatables and a way of linking them (such as adding a groupid field depending on whether active or not). Then add a data relation based on this column. Now set the grid's datasource to this dataset and you will get a master details gridview.
Avatar of andre72
andre72

ASKER

CodeCruiser, do you have a small sample of you solution No. 2 (DataSet)?
This sounds fine for me ...
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andre72

ASKER

Thanks for your support
Glad to help :-)