Treeview Events and References
Posted on 2004-11-25
I am working with a Treeview for the first time, and would like to do the following:
I have a Treeview control on a form with a subform containing a tab control.
The tab control has tabs for Customer, Location, Service, and Visit. These correspond to the levels in my Treeview. The Customer, Location and Service tabs are full of simple text fields. The Visit tab contains a third-party calendar control showing the specific Visits for this Service.
I want to do two basic things:
1. When the user clicks on a node in the treeview, I want to detect what type of node that is, and display the relevant details about that node in the sub-form. If it is a Customer, I want to display the Customer information tab and hide the Location and Service tabs (I can handle that). If it is a Location, I want to display the Location tab, and hide the Customer and Service tabs, etc.
Q: How do I best figure out what type of node the user has clicked? Should I use a naming convention? Should I keep an array on the side and use an index value? Something else? Is there a property which tells me the level in the tree?
2. When the user clicks on the calendar control and chooses an appointment, I want to find the relevant customer, display all Locations and Services in the Treeview, and then move to the specific Visit corresponding to the one he just clicked.
Q: How do I locate a specific node within a tree? Do I use some kind of index value? How are these best tracked? An array outside the Treeview?
Other things which would be helpful would be a reference to all available properties and events within the Treeview, and sample code for doing things similar to the above.
Thanks very much. Ted