Results 1 to 4 of 4

Thread: Fill Treeview

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Horst
    Posts
    262

    Question 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

  2. #2
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    need to know where the data comes from. Is it in a db, flat file, xml, or in code?
    Magiaus

    If I helped give me some points.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Horst
    Posts
    262
    Hi Magiaus,

    the data is coming from an Access 2000 DB (making plans to migrate to SQL - S.)

    Sander

  4. #4
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    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.....
    Magiaus

    If I helped give me some points.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width