the_b1ackfox
asked on
Displaying data in a C# winform
Hello Expert developers,
Traditionally I have used the datadridview to display information from a database. Now I have a need to display data under a title like this:
Bob Johnson
Invoice 1
Invoice 2
Meeting Notes
Brad Smith
Blah blah
Blah blah blah
I would like the name and the items under the name to be items I could click on and do something with (if possible) if not, what could I use to display data like this?
Fox
Traditionally I have used the datadridview to display information from a database. Now I have a need to display data under a title like this:
Bob Johnson
Invoice 1
Invoice 2
Meeting Notes
Brad Smith
Blah blah
Blah blah blah
I would like the name and the items under the name to be items I could click on and do something with (if possible) if not, what could I use to display data like this?
Fox
A tree view ?
ASKER
Hello Andy, do you have a good reference on populating the tree view?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Is there any other control that can do something like this?
rick_gwu: I have the data in a dataset, but how could you manipulate the data source for this?
rick_gwu: I have the data in a dataset, but how could you manipulate the data source for this?
Are the data fields common to all users?
Bob Johnson
Invoice 1
Invoice 2
Meeting Notes
Brad Smith
Invoice 1
Invoice 2
Meeting Notes
Otis Spunkmeyer
Invoice 1
Invoice 2
Meeting Notes
etc.... ?
What does your data row look like?
Bob Johnson
Invoice 1
Invoice 2
Meeting Notes
Brad Smith
Invoice 1
Invoice 2
Meeting Notes
Otis Spunkmeyer
Invoice 1
Invoice 2
Meeting Notes
etc.... ?
What does your data row look like?
>>Is there any other control that can do something like this?
What do you mean? Display in a tree structure but it isn't a tree ?
You could use a gridview but it won't look like a tree.
What do you mean? Display in a tree structure but it isn't a tree ?
You could use a gridview but it won't look like a tree.
ASKER
Rick, your initial comment got me thinking... about manipulating the associated data and I found that with the right amount of manipulation you can indeed have your data in a dataview, and sort of like a tree view. I will post an example (and no, I didn't come up with it, you guys just prompted me to ask the right questions), and split the points
ASKER
Here is a sample that produces the data as hoped but in a format I could stuff into a data grid:
select
'Bob' c1, 'Barker' c2, ' Blah' c3, ' blah' c4, ' blah' c5, ' blah' c6 into #tmp
insert into #tmp
values ('Bob','Barker','Blah1','b lah1','bla h1','blah1 ')
insert into #tmp
values ('Bob','Barker','Blah2','b lah2','bla h2','blah2 ')
insert into #tmp
values ('Rob','Barker','Blah1','b lah1','bla h1','blah1 ')
insert into #tmp
values ('Rob','Barker','Blah2','b lah2','bla h2','blah2 ')
-- get results
-- column rn needed for ordering your results
WITH t_CTE (rn, c1, c2, uname, cnt)
AS
-- Define the CTE query.
(
SELECT rOW_NUMBER() OVER(ORDER BY c1, c2), c1, c2,c1+' '+ c2 uname , COUNT(*) as cnt
FROM #tmp
group by c1, c2,c1+' '+ c2
)
SELECT ' ' name ,c3+','+c4+','+c5 blah
, (ROW_NUMBER() OVER(ORDER BY t.uname)) + power(100,rn) AS rn
FROM #tmp u join t_CTE t on u.c1=t.c1 and u.c2=t.c2
union all
select uname,''
, power(100,rn) from t_CTE t
order by rn
select
'Bob' c1, 'Barker' c2, ' Blah' c3, ' blah' c4, ' blah' c5, ' blah' c6 into #tmp
insert into #tmp
values ('Bob','Barker','Blah1','b
insert into #tmp
values ('Bob','Barker','Blah2','b
insert into #tmp
values ('Rob','Barker','Blah1','b
insert into #tmp
values ('Rob','Barker','Blah2','b
-- get results
-- column rn needed for ordering your results
WITH t_CTE (rn, c1, c2, uname, cnt)
AS
-- Define the CTE query.
(
SELECT rOW_NUMBER() OVER(ORDER BY c1, c2), c1, c2,c1+' '+ c2 uname , COUNT(*) as cnt
FROM #tmp
group by c1, c2,c1+' '+ c2
)
SELECT ' ' name ,c3+','+c4+','+c5 blah
, (ROW_NUMBER() OVER(ORDER BY t.uname)) + power(100,rn) AS rn
FROM #tmp u join t_CTE t on u.c1=t.c1 and u.c2=t.c2
union all
select uname,''
, power(100,rn) from t_CTE t
order by rn