Tree view and Datagrid

  • Thread starter Thread starter Kishor
  • Start date Start date
K

Kishor

Hi,



In Visual basic6 there are so many grids using which we can display the tree
structure (Multiple column). Same thing I am planning to display the result
of query in a tree format, instead of grid. I wanted to know how to convert
this data grid in to a tree view?. I am using vb.net as a development
language. I am having records in this format



ID Colmn1 Colmn2 Colmn3 Colmn4 ParentId.



First column Id and last column ParentId will be not visible to the user.



Please suggest me some kind of solution for this.





Regards

Kishor
 
1 way of doing this
(i don't know how you want to display it exactly, ill give you 1 possibility
you should be able to work from that)

create a class that holds the data (i would suggest putting the code to
manipulate the data in this class 2)
put your data in a dataset
(code not tested don't shoot me if i have some names wrong)
'building the tree
dim node, node2 as treenode
dim c as yourClass
dim r as datarow

tree.clear
for each r in dataset.tables(0).rows
'create a constructor in your class that handles the vars and cast them
c = new yourClass(r(0),r(1),r(2),r(3),r(4),r(5))
node = new treenode
node.text = r(1)
node.tag = c
for i as integer = 1 to 4
node2 = new treenode
node2.text = r(i)
node.nodes.add(node2)
next
tree.nodes.add(node)
next

now you can use the events of the tree to access your class and manipulate
the data (if you use this you will need to reload the tree)

as i said its 1 way of doing this, i don't like working bound but thats
another option.

hope it helped

eric
 
Hi Kisthor,

Data in a treeview has a "Tree" structure, while in datagrid mostly a flat
structure.
What you describe looks for me a flat structure.

So maybe you can better have a look for a "listview" and then in a
combination if that is necessary with the"treeview", then you get the
explorer look.

I hope this helps a little bit?

Cor
 
Hi,

I am having this component with me but there is a issue of accessibility
with this grid, so I can not use this grid.

This is why I am planning to use data grid which comes free with .net
studio. My problem here is I dont know how to convert this Data grid to
tree.

please tell me if you have any suggestions

Thanks

Kishor
 
i'm afraid you can't do that w the default datagrid

if i'm not mistaking the grid in the resource kit is from infragistics. They
have newsgroups of their own you could try there.

Eric
 
Back
Top