A Native TreeView (Part I)

Version: 1.00.10 - Last Update: Tuesday the 29th, September 2009 - 11:20:00

Previous ChapterComplex Controls Home (TOC)Next Chapter 

FoxPro Rocks! This is all about how to create complex controls using native VFP only!


I'll wager, once in a while every VFP developer thought about raising his own home-grown VFP-TreeView. I mean no ActiveX magic but using only native Visual FoxPro code. I must admit I was one of them – until I found some inspiration and finally... did it. You may follow the next link to get a first idea. Thanks to Craig's tips I was able to add the missing feature to my DynaViews: Hierarchical Display

Alpha version of my TreeView Grid
Figure #1: Alpha version of my TreeView Grid

Within the next weeks I'm going to show you how to teach a VFP grid to behave like some full-featured MS-TreeView.

Because there are no limitations within VFP we will end up with a table-driven TreeView that has more functionality than Microsoft's ActiveX control, loads lightning fast, can be configured any way you can dream of and much, much more!

Before we dive into building that very complex TreeView, let’s find something more basic; some less complex control which can be implemented a little bit easier - hopefully.

All GUI controls can be classified basically by their usage. Some are used to enter data; some are used for display only the rest is used for all kinds of navigation purposes. Of course there are no fixed boundaries. One can find almost everything from simple half-breeds up to all-in-one devices suitable for every purpose.

A TreeView is used for navigation and display. Apart from caption editing Microsoft’s “bare-bone” TreeView has no native data editing capabilities. A TreeView has the extended ability to display hierarchical related data (compared to a ListView or a popup menu). Unless we have to implement this “parent-child-indentation” thing, our TreeView would look like a scrollable list. That’s why it sounded like a good idea to me to start my research creating some kind of ListView based on VFP’s Grid. To spice things up a little bit I decided that this new ListView class can be used as a Right-Click Menu.

Previous ChapterComplex Controls Home (TOC)Next Chapter



  1. Hi Burkhard

    I was pointed to your blog by Bernard Bout on his blog and I am totally impressed by your posts. Hope you have been recovering well from your stroke you mentioned in your latest post.

    I was curious if you have that Native TreeView created as you had displayed it on your first post about native treeview.

    Please keep up the good work

  2. Yes - I was wondering the same - did you ever get to the Native Treeview -

    I see a a lot of stuff dedicated to the right click, but I am very interested in the Treeview


  3. Did this ever work?
    I don't get the theory yet.

    It is beginning to look like a hoax


  4. Hoax? That's a tad unfair considering Burkhard's health problems recently.

    It would be nice to see the finished article for the treeview though, or at least the source code so mere mortals can play around with it :)

  5. Daniel fedormorales@yahoo.esThursday, March 04, 2010

    can you share your native treeviwe code???

  6. Hi, it's wonderful. Exactly what I need in the moment...

    Can you share with us this example of native treeview?

    I'm having troubles with ActiveX Treeview and I found only this alternative, your sample.



  7. @Rafa
    Yep, I am working on it! But I still have to make some speed improvements first. Actually I'm integrating that VFP-based TreeView component in one of my own applications - and, as you may guess, ran into several issues when trying to displaying huge trees (with more than 30000 nodes on more than 10 nested levels).
    Beside that I've started using C# with the latest VS2010 which burns up most of my free time...