Click to See Complete Forum and Search --> : Treeview


Hank Scott
September 15th, 1999, 05:02 AM
I'm working in Access 97 on an equipment tracking database and have the structure ironed out pretty well. On the left side of my main data viewing form I've added a treeview control using the treeview control wizard from Microsoft's site that shows all the Locations as Primary Nodes and the names of the Equipment in those locations as child nodes. "Locations" is a small table with the location name field as the primary key utilizing a one to many relationship with referential integrity with the Equipment table's "Location" field. The wizard set up everthing that you see pretty well...just nothing you'd need to DO.

I've been trying to figure out how to do a few things:

Assign unique icons to each child node based on what the piece of equipment is. (i.e. based on the Equipment Table's "Catagory" field, monitor icon for a monitor, cpu icon for a cpu, etc.)

Have information on the right side of my form change to show more detail (serial number, tracking number) based on what piece of equipment is selected in treeview (This could be in a listview control, or with regular form controls based on the Equipment Table's fields)

Enable drag and drop so I can move pieces of equipment from one place to another and have this action update the database.

Enable renaming of locations that whould also rename the corresponding location in the Locations table.

I've looked all over the net and the treeview control is not that well documented when trying to use it to view and manipulate database information in Access.

Any help on any of these points would be greatly appreciated.

~Hank

Chris Eastwood
September 15th, 1999, 05:20 AM
Hi Hank


>I've added a treeview control using the treeview control wizard from
>Microsoft's site

I've never heard of that - what's the url to download it ?


>I've been trying to figure out how to do a few things:

>Assign unique icons to each child node based on what the piece of
>equipment is. (i.e. based on the Equipment Table's "Catagory" field,
>monitor icon for a monitor, cpu icon for a cpu, etc.)

If you assign an ImageList with lots of different Icons to the TreeView you can simply set the Node's Icon property at runtime.

>Have information on the right side of my form change to show more detail
>(serial number, tracking number) based on what piece of equipment is
>selected in treeview (This could be in a listview control, or with
>regular form controls based on the Equipment Table's fields)

I'd recommend building a UserControl for each type of equipment that you have in your database. If you store the 'equipment type' in the tag of the node (or somewhere else), you'll be able to display to appropriate control on the RHS of the screen.

>Enable drag and drop so I can move pieces of equipment from one place to
>another and have this action update the database.

If you are using VB5 this is great. The Control allows you to reparent a node (and it's children) almost instantly. If you use the VB6 version of the Common Controls, this is really ugly, and for somereason, reparents every child node underneath the one you are reparenting. I emailed M$ about this a few months back and never got a reply.


>Enable renaming of locations that whould also rename the corresponding
>location in the Locations table.

Take a look at the 'LabelEdit' properties of the nodes in the Treeview. This allows you to rename a node and then raises an event which you can catch to rename the item in the database.


Most of what you've asked for above can be found in the source code for the VBCodeLibrary at :

http://codeguru.developer.com/vb/articles/1724.shtml

This application shows items from a database in a tree-view and allows you to drag/drop, rename etc - there should be lots of code in that project you can steal / use to your advantage.





Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb

Hank Scott
September 15th, 1999, 07:37 AM
Thanks for all the tips, I'll be going through that code library for for a while...
The url for the Treeview Control Wizard is
http://support.microsoft.com/download/support/mslfiles/WzTreevw.exe

It doesn't work in Access 2000 though and it won't convert to Access 2000 format. I wish they would update it...maybe make it more funtional?

As far as VB5 and VB6 differences in these controls, Microsoft has a utility to convert your controls and code from comctl32 to mscomctl. You'll have to search their knowlege base for that one, but it seems like it would take the pain out of the upgrade.

~Hank

Hank Scott
September 15th, 1999, 07:40 AM
The Conversion utility is here...
http://msdn.microsoft.com/vbasic/downloads/ProjUpgd.EXE
It it for VB6, I suppose, to upgrade form controls to the latest versions.

~Hank

Chris Eastwood
September 15th, 1999, 08:22 AM
>Thanks for all the tips, I'll be going through that code library for for
>a while...
>The url for the Treeview Control Wizard is
>http://support.microsoft.com/download/support/mslfiles/WzTreevw.exe

Thanks for the link - I'll download it now


>As far as VB5 and VB6 differences in these controls, Microsoft has a
>utility to convert your controls and code from comctl32 to mscomctl.
>You'll have to search their knowlege base for that one, but it seems like
>it would take the pain out of the upgrade.


What I meant was that I program in VB6, but only use the VB5 controls. The VB6 ones are so full of bugs, but most people don't notice because they are so 'wowed' out by the fact that you can have different coloured items in treeviews / listviews.

[unrelated rant]
I'm amazed at MicroSoft releasing the controls in the state that they are in with VB6 - I won't be using the mscomctl.ocx until they link it dynamically with the comctl32.dll like they did with the version 5 controls. As it is, you can't use the API to get any of the new functionality of the IE5 update to the comctl32.dll (such as the header/filter within a listview). The bugs in the treeview for reparenting are completely unacceptable - it's actually quicker to remove the nodes and add then manually than trying to reparent a node with the mscomctl.ocx version.
[/unrelated rant]



Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb