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
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
ASKER
CodeCruiser, do you have a small sample of you solution No. 2 (DataSet)?
This sounds fine for me ...
This sounds fine for me ...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your support
Glad to help :-)
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.