Re: Filling a Treeview with query




"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

.



Relevant Pages

  • Re: Ever done this in a miata?
    ... ->opened the door of my red miata and thought "whoa, ... ->steering wheel and boost gauge"? ... It happened to me once, same color car, etc. at a Home Depot. ... The door was locked on the car, ...
    (rec.autos.makers.mazda.miata)
  • Re: Defeating 2002 E-320 seat belt and Remove Key alarms
    ... On my car the seat belt warning system never activates, ... I received a leather steering wheel cover that had to be laced on by hand. ... It really took us both to do the job, so I opened the door so she could be ...
    (alt.auto.mercedes)
  • Re: 1987 Corolla SR5 front suspension repair
    ... anything new on the car, ... front left wheel bearing noise --pot hole strike-related? ... I'll get back to this after the control arm and wheel bearing are fixed. ... In the ball joint, the neck of the ball might also be ...
    (alt.autos.toyota)
  • Re: McLaren brake ducts
    ... which of course move relative to the unsprung part of the car - are ... not aerodynamic devices and thus not movable aerodynamic devices as ... That effectively wiped out the wings in use ... In this particular case the wheel fairings don't generate downforce ...
    (rec.autos.sport.f1)
  • Re: 79 300TD "needs new vacuum hoses"
    ... all-new hoses? ... It turns out that it's not nearly that bad, so I bought the car today. ... doors, fuel door, and hatch don't lock when I turn the key in the driver ... this car does have the auto climate control. ...
    (alt.auto.mercedes)