Re: Filling a Treeview with query
- From: "MikeD" <nobody@xxxxxxxxxxx>
- Date: Tue, 28 Mar 2006 19:34:45 -0500
"Jordan" <nojunk_allowed@xxxxxxxxxx> wrote in message news:urEoHDsUGHA.6048@xxxxxxxxxxxxxxxxxxxxxxx
I need advice on the logic on filling a tree view with a query that needs to make multiple passes at a product structure table. I am trying to create a multi-level Bill of Material for viewing. A sample of data in the table looks like this:
Part - Component
================
Car - Wheel
Car - Doors
Car - Seats
Wheel - Tire
Wheel - Rim
Door - Glass
Door - Handle
I want to end up with a TreeView that looks like:
Car
- Seats
- Wheel
- - Tire
- - Rim
- Doors
- - Glass
- - Handles
I can easily get the first level of the B.O.M. with the query:
Select * from [Product Structure] Where [Part] = "Car"
But I am a little lost on the best practices for cycling through the tree control for adding each of the levels.
I'd get everything in ONE query so there'd be no need to hit the DB multiple times. Use keys when adding nodes to the treeview. For example, your top level would have the key "cars". You can then more easily add the child nodes (Seats, Wheel, and Door) to that.
A lot of this will have to do with the recordset that you're getting from your SQL statement. Don't use *. Just return the columns that you actually need.
I would give you example code, but I just reformatted my hard drives, reinstalled Windows (3 versions of it), and haven't yet gotten around to re-installing VB (or much else at this point).
--
Mike
Microsoft MVP Visual Basic
.
- References:
- Filling a Treeview with query
- From: Jordan
- Filling a Treeview with query
- Prev by Date: Re: Is my Control a cotrol array ??
- Next by Date: Re: Is my Control a cotrol array ??
- Previous by thread: Filling a Treeview with query
- Next by thread: Re: Filling a Treeview with query
- Index(es):
Relevant Pages
|