TDBSortGrid =========== Version 1.03 (24 March 1998) Freeware for Delphi 1.0 and 2.0 Copyright (c) 1998 Greg Lief ---------------------------------------------------------------------------- 1. Description 2. Installation 3. Properties 4. Events 5. Usage Notes 6. Copyright Notice 7. Disclaimer 8. Technical Support 9. Revision History 10. Comments 11. Purchasing Source Code ---------------------------------------------------------------------------- 1. Description ============== This is a TDBGrid derivative that will automatically re-order its data when one of its column headings is double-clicked. If you are using Delphi 1, this component will only work when attached to a TTable. The 32-bit version will handle both TTables and TQueries. 2. Installation =============== A. Choose the Component | Install menu option (or if you are using Delphi 1.0, the Options | Install Components menu option). B. Click upon the Add Button, and select either DBSG16.DCU (Delphi 1) or DBSG32.DCU (Delphi 2). C. Press OK twice. D. After your component library is recompiled, you will find a new tab entitled "Greg Lief", with the TDBSortGrid icon upon it. 3. Properties ============= SelectedColor -- This allows you to change the color of the font used for the column heading currently used for the sort order (whew! talk about a long sentence). The default value is clRed. NOTE: This applies only to the 32-bit version. 4. Events ========= OnResort -- This event allows you to react if/when the user decides to resort the grid. Here is the syntax for your event handler: procedure OnResort(Grid : TDBSortGrid ; ColumnIndex : integer ) Grid is the grid with which you are working. ColumnIndex is the zero-based ordinal position of the column which now dictates the sort order. For example, you can use this as a lookup into the grid's Columns property. 5. Usage Notes ============== The most important thing to remember is that when you use this component in conjunction with a TTable, you must have a secondary index for each field in order for the sort to take place. If the user double-clicks upon a column heading and there is no index available for the field in that column, the user will get the "cannot sort on this column" error. As mentioned above, the Delphi 1 version of this component will only work with TTables. The Delphi 2 version will work with TQueries, but be warned that if your query (SQL property) already includes an ORDER BY clause, anything from that point forward will be truncated. (I didn't have time to put in smarter parsing, sorry.) Also note that the dgColumnResize option is initially disabled. This is to avoid the flickering that would otherwise occur when double-clicking upon a column heading. (Turn it back on and you'll see exactly what I mean.) 6. Copyright Notice =================== This component is fully functional. My copyright notice will appear when you drop it upon a form at design-time, but that will not occur at run-time. You can remove the copyright notice by purchasing the source code (see item #10 below). 7. Disclaimer ============= It is unfortunate that we live in a litigous society in which the lawyers are generally the only winners. However, that makes the following verbiage necessary: "THE CODE FOR THIS COMPONENT IS PROVIDED TO YOU AS IS BY ITS AUTHOR, GREG LIEF. THE AUTHOR HAS TESTED THE COMPONENT AND FEELS THAT IT WORKS AS BILLED, BUT MAKES ABSOLUTELY NO GUARANTEES OR WARRANTEES OF ANY KIND. IN OTHER WORDS, YOU ARE USING THIS ENTIRELY AT YOUR OWN RISK. NEITHER THE AUTHOR NOR ANY OTHER ORGANIZATION WILL BE HELD RESPONSIBLE FOR ANY DIRECT OR INDIRECT DAMAGE RESULTING FROM THE USE OF EITHER THIS COMPONENT OR ANY DERIVATIVES THEREOF." 8. Technical Support ==================== The reason I am making this component available as freeware because I feel that it will be of use to other Delphi developers. However, always remember the old maxim "you get what you pay for". In other words, do not get carried away by expecting technical support, because you will be sadly disappointed. 9. Revision History =================== Mar 24, 1998 -- version 1.03: added OnResort event. Mar 21, 1998 -- version 1.02: made index search more flexible (i.e., index names no longer need to match field names). Also added SelectedColor property. Jun 09, 1997 -- version 1.01: optimized so that the user cannot re-sort the current column (especially important with queries) Feb 14, 1997 -- initial public release 10. Comments ============ If you find this component useful, I would appreciate hearing from you via e-mail (greg@greglief.com). If you would like to learn how to create your own components, you should strongly consider my Delphi Expert seminar. For more information, visit: http://www.objectlessons.com/seminars.shtml. The most updated version of this component can always be found at my personal web site (http://www.greglief.com). 11. Purchasing Source Code ========================== The TDBSortGrid source code is available for $5 US. See the ORDER.TXT (included in this package) for more details.