The Visual FoxPro Grid ControlI've often been heard to say that Visual FoxPro's grid is one of the greatest controls ever devised. I still feel that way, but wouldn't it be nice if some of the functionality that our customers want implemented in the grid came stock? You know, features like: sorting, filtering, incremental search, saving user preferences, and exporting to Excel. It'd be even cooler if this type of functionality could be implemented on any Visual FoxPro grid (regardless of the recordsource) by simply dropping a class on a form, setting a single property and writing a single line of code. Well, that's what I have set out to create with the class I present in this blog entry.
First Shown at Southwest Fox 2008At Southwest Fox 2008, I presented a session entitled "Creating a Professional VFP Application from Start to Finish" in which I showed an earlier version of GridExtras. I've improved on it since then, so if you attended Southwest Fox 2008 you may want to get the control and sample from here rather than the session download. For those of you that didn't attend Southwest Fox 2008 (you should have - it was a blast!), you can see the basic functionality provided by GridExtras in the screenshots provided at the bottom of this blog entry.
How to Use the ClassI've provided a sample.exe application in the download so you can try it out and see how it's implemented. However, the basic steps are:
That's all there is to getting GridExtras up and running for a grid in your application. As I say, I've included a sample in the download, so if you have any questions about how this is done just review the sample or you can post a comment here on my blog and I'll do my best to answer it.
Other Properties of NoteThere are a few other GridExtras properties you may want to take note of and use, such as:
What's NextJust have fun with GridExtras and see if it's useful to you and your applications. In a perfect world, you'd find some way to improve it (add additional export formats, provide a column lock feature, etc.). If you do improve GridExtras, I'd appreciate it if you would contact me and share the improvements you've implemented. Thank you in advanced to those of you that decide to do so.
Until next time... Visual FoxPro Rocks!
Download GridExtras and Sample (approx. 170 KB)
Figure 1: GridExtras provides sorting, incremental search, and filtering capabilities to any Visual FoxPro grid.
Figure 2: GridExtras has additional features such as the ability to go semi-transparent and the ability to save the user's preferences (column order and width).
Figure 3: In addition to the features provided by GridExtras through a grid's column headers, there is also an icon added to the bottom right of the grid that allows the user to access the "Grid Templates and Export" screen seen in Figure 4.
Figure 4: The grid templates help the user save grid views so they can recreate them quickly in the future. The export feature of GridExtras can create XLS, XLSX, XLB, and XLM Excel formats. The grid's header captions are used to name the Excel columns when data is exported.
Remember Me
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u