-
Fill Treeview
Hi group,
I need to fill a treeview in a C# winform app with nodes (root, childs, sibblings…)
I’ve got a table with these fields:
ChildID (number) Primary Key
Item (text)
ParentID (number)
Here’s some example data:
ChildID Item ParentID
1 Item 1 0
2 Item 1.1 1
3 Item 1.1.1 2
4 Item 1.2 1
5 Item 2 0
6 Item 2.1 5
I need to create a tree like this:
ROOT
- Item 1
o Item 1.1
§ Item 1.1.1
o Item 1.2
- Item 2
o Item 2.1
I know how I can add nodes childs and sibbling to a treeview but how do I create something (array, DataReader, whatever) to build the above?!
TIA
SD
-
need to know where the data comes from. Is it in a db, flat file, xml, or in code?
-
Hi Magiaus,
the data is coming from an Access 2000 DB (making plans to migrate to SQL - S.)
Sander
-
I don't have that code handy and I'm to tired right now to write imaginary code...
You need a connection a command and an adapter. oledb.. setup the connection and command to get data with say a select statement and set the adapter to use them then you use the adapter to fill a datatable in a dataset or just use the datatable.
I don't know about binding a treeview.
If you still need help I'll be more useful after I get some sleep.... I think I'll be dreaming about regions and pixels.....