TSortGrid 1.30, Freeware component (read Agreement) for Delphi 2-4
  by Karsten Bendsen.

Hi, Delphi user.
 As I have been unable to locate Bill Menees (The original Author) somewhere
on the internet, I will continue working on his component.

Please contact me on koger@iname.com, if you have found a bug, made a change or
 .. then email me.

You can also get the newest version from my homepage www.koger.cjb.net

This component has taken hours and hours to create, so you could at least read the
Agreement and Missing features chapter.



1. Agreement

2. Known Bugs

3. Overview

4. History

5  Missing Features

6. Disclaimer


*****Agreement*****************************************************************

You must see the missing features chapter and if you know an sollution to any
of these question, please mail me.

This component is only freeware in freeware programs, you are NOT alowed to use
this component in shareware or any other commerciel programs!!

If you use this component, please let me know.



*****Known Bugs****************************************************************

Complete Boolean Eval. MUST be UNchecked, you can set this settings in project
options, this will genereate an error when a null-string is tried to be read.

Some of the Sort-procedures uses exceptions, which mean you will get a lot of 
errors when running the program from Delphi, you might turn Break On Exception 
off, Delphi 4: Menu|Tools|DebuggerOptions|Lan. Ext.|Stop on.. to prevent this.

When the BeginUpdate and the rowcount changes, TSortGrid will resorted, this 
might sometimes cause an error so you might put a pair of bracers {} around
the code located under "OnSizeChange", or use Begin..EndUpdate



******Overview*****************************************************************

A short listing of the most interesting procedures, you may check the code out
for more information.

TSortGrid is a highly improved TStringGrid, lots of new or improved functions,
to name a few:
Search & Filter, Sort, Load & Save, Real MultiSelect, Print, Auto size Columns
and much more.

New Procedures and Functions:
AutoSizeCol, AutoSizeColumns, Clear, BeginUpdate, EndUpDate,GetCellDrawState,
MoveTo, InsertRow, InsertColumn, DeleteRow, DeleteColumn, MoveRow, MoveColumn,
SwapRows, SwapColumns, LoadFromFile, SaveToFile, GetSelectRow, GetSelectRowCount
SetSelectRow, FindFirst, FindNext, SortColumn, Print, PrintPreview, PageCount

New Properties:
AlignmentHorz, AlignmentVert, BevelStyle, Modified, Sorting, ExtendedKeys,
ProportionalScrollBars, MultiSelect, Filtered, SearchCol, SearchText, 
SearchCaseSen, SortCaseSensitive, SortStyle, SortCol, SortDirection, 
UpdateOnSizeChange

New Events:
SizeChanged, OnGetCellFormat, BeginSort, EndSort, RowInsert, RowDelete, 
ColumnInsert, ColumnDelete, ColumnWidthsChanged, RowHeightsChanged


Contents

*Misc procedures and functions
*Misc Properties
*MultiSelect
*Search and Filter
*Sort
*Print
*Cell Format
*New Events


-Misc procedure and functions-------------------------------------------------

procedure AutoSizeCol(const ACol: LongInt);
  Resize the column to fit the text with

procedure AutoSizeColumns;
  Resizes all columns

procedure Clear;
  Clears the StringGrid

procedure BeginUpdate;
  Call this to modify the Grid faster and to prevent flicker

procedure EndUpDate;
  Always call this when you have updated the Grid

function GetCellDrawState(const ACol, ARow: Longint): TGridDrawState;
  Returns the state of the Cell

procedure MoveTo(ACol, ARow: Longint);
  Moveto the cell and selects it

procedure InsertRow(ARow: Longint);
  Inserts a new empty row at ARow

procedure InsertColumn(ACol: Longint);
  Inserts a new column

procedure DeleteRow(ARow: Longint);
  Remove a row

procedure DeleteColumn(ACol: Longint);
  remove a column

procedure MoveRow(FromIndex, ToIndex: Longint);
  Move a row from "FromIndex" to "ToIndex", no rows deleted!

procedure MoveColumn(FromIndex, ToIndex: Longint);
  As MoveRow, just a column

procedure SwapRows(ARow1, ARow2: Longint);
  Exchange two rows, you might also see MoveRow

procedure SwapColumns(ACol1, ACol2: Longint);
  Exchange two Columns

procedure LoadFromFile(const FileName: String);
  Loads contenst from FileName

procedure SaveToFile(const FileName: String; SaveWidth: Boolean);
  Saves contenst to FileName


-Misc properties--------------------------------------------------------------

property AlignmentHorz: TAlignment;
  Set the horizontal alignment for how the text should apear in the cells

property AlignmentVert: TVertAlignment;
  Set the vertical alignment for how the text should apear in the cells

property BevelStyle: TCellBevelStyle
  Set the bevelstyle for the Cells

property Modified: Boolean (Runtime)
  if true the grid is modified

property Sorting: Boolean (Runtime and Readonly)
  if True the grid is being sorted

property ExtendedKeys: Boolean
  If true and the grid is not in editor mode, then
   Ctrl + INSERT:         InsertRow
   Ctrl + DELETE:         DeleteRow
   Ctrl + Shift + INSERT: InsertColumn
   Ctrl + Shift + DELETE: DeleteColumn

property ProportionalScrollBars: Boolean
  Normal or proportional ScrollBars

property UpdateOnSizeChange: Boolean
  Resorts the grid when either RowCount or ColCount is changed


-MultiSelect------------------------------------------------------------------

MultiSelect: Boolean
  Is it posible to select multiply rows

  function GetSelectRow(ARow: Integer): Boolean;
    Returns true if Arow is selected otherwise false. *If you remove a selected
    row you should manually call SetSelectRow so the row isn't focused anymore.
    ex. The last row is selected, then SortGrid1.RowCount := SortGrid1.RowCount-1
    you should then call SetSelectRow(SortGrid1.RowCount+1, False);
 
  function GetSelectRowCount: Integer;
    How many row(s) are selected.
  
  procedure SetSelectRow(ARow: Integer; Selected: Boolean);
    Manually (de)select a row.

 
-Search and Filter------------------------------------------------------------

SearchOptions:
  property Filtered Boolean
    Only displays rows that has SearchText in them

  property SearchCol Integer
    Search or filter this Column, if SearchCol -1 all Columns will be searched

  property SearchText String
    The search-text

  property SearchCaseSen
    If true perform a CaseSensitive search

function FindFirst: Boolean;
  Search from the first row

function FindNext: Boolean;
  Search starts after the last selected row

-Sort-------------------------------------------------------------------------

SortOptions

  property SortCaseSensitive: Boolean;
    If checked the Grid is sorted CaseSensitive

  property SortStyle: TSortStyle
    Choose how the Grid should be sorted. Extended Sort, sorts both Alpha and
    Numbers correct that means A1,A10,A2 are listed as A1,A2,A10, normaly this 
    would be A1, A10, A2.

  property SortCol: Integer; (RunTime-ReadOnly)
    Which column is currently sorted
  
  property SortDirection: TSortDirection; (RunTime-ReadOnly)
    Can be sdAscending or sdDescending, which direction is the column sorted.

  procedure SortColumn(ACol: Integer);
    Sorts ACol, after the specified SortOptions.
 
  or you can just click the header to sort the column.


-Print------------------------------------------------------------------------

procedure Print;
  Fill out PrintOptions and then call print to actually print the grid

procedure PrintPreview(Image: TImage);
  Fill out PrintOptions and enter a Image on which the preview should be drawed
 
function PageCount: Integer;
  Returns the number of pages on the grid

PrintOptions
  property JobTitle: string;
    Named display in printer spool

  property PageTitle: string;
    Name displayed at the top of page

  property Copies: Cardinal;
    Number of copies to be printed

  property FromRow;
    Print from row, don't set this to 0 as this row is already included

  property ToRow: Cardinal;
    Print to this row

  property PreviewPage;
    make a preview of this page
  

-Cell Format------------------------------------------------------------------

  procedure OnGetCellFormat(Col, Row: Longint; State: TGridDrawState; 
                                           var FormatOptions: TFormatOptions)

    TFormatOptions = record
      Brush: TBrush;
      Font: TFont;
      AlignmentHorz: TAlignment;
      AlignmentVert: TVertAlignment;
      Bevel: TCellBevel;
      HideText: Boolean;

    Set the CellFormat for each cells, click the OnGetCellFormat and write your
    own display options.
    
    e.g.
    begin
      if Row = 0 then
        FormatOptions.Font.Color := clBlack;
    end;


-New Events-------------------------------------------------------------------

  procedure SizeChanged(OldColCount, OldRowCount: Longint)
    Triggers when the RowCount or ColCount changes.

  I won't comment the following Event as can figure out yourself what they do
  procedure BeginSort, 
  procedure EndSort
  procedure RowInsert:
  procedure RowDelete:
  procedure ColumnInsert:
  procedure ColumnDelete:
  procedure ColumnWidthsChanged:
  procedure RowHeightsChanged:


Well I guess that it, remember to email me at koger@iname.com with comments, 
suggestions or whatever.


*******History******************************************************************

  TSortGrid 1.21
    Modified by Eric W. Engler, Feb 1997
    - fixed a bug in autodetection of type
    - OnBeginSort event was called before the autodetect of type; moved to after.
    - expanded date sort to incl datetime (these are usu compatible in Delphi)
    - added a time sort

    Modified by koger@iname.com
    - Fixed a little fix in MoveTo
    - Fixed a bug with Clear;
    - Added better Save and Load procedure
    - Added Extended Sort, a bit slow, but sorts both alpha and numbers correct.
    - Also create sortoptions, so they are easiere to use
    - Added nice Bitmap to show SortDirection    
    - (Added filter and search functions)
    - MultiSelect, still some small bugs
      Most of the code for MultiSelect was original written by Tom Lee,
        tom@libra.aaa.hinet.net 
    - Fixed a lot of bugs, don't want to use time telling you which, as they 
      are removed anyway.

  TSortGrid 1.30
    - Added UpdateOnSizeChange: Boolean
    - Added SecondaryIndex
    - Added Sorted column don't change when moving columns 
    - Added The grid can now be printed
    - Fixed error with two TSortGrids, thanks to Ralf Schiener
    - Fixed error with extended sort mode, thanks to Ralf Schiener
    - Fixed error with jump to row on single key press
    - Fixed MoveTo also makes column visible



*******Missing features*********************************************************

The selected ColumnHeader isn't lowered
No HotTrack as in TListView
No Column property as in TListView
Colwidth don't change WHEN resizing column
Can't center nametitle with Printer.Canvas (see DrawToCanvas | DrawTitle)
Still some small bugs in MultiSelect



*******Disclaimer**************************************************************

TSortGrid 1.2+ Copyright by Karsten Bendsen

Standard Disclaimer:  This software is provided AS IS without warranty of any 
kind, either expressed or implied.  The entire risk as to the quality and 
performance of the software is with you.  Should the software prove defective,
you assume the cost of all necessary servicing, repair, or correction.  In no
event shall the author, copyright holder, or any other party who may 
redistribute the software be liable to you for damages, including any general,
special, incidental, or consequential damages arising out of the use or
inability to use the software (including, but not limited to, loss of data, 
data being rendered inaccurate, loss of business profits, loss of business 
information, business interruptions, loss sustained by you or third parties, 
or a failure of the software to operate with any other software) even if the 
author, copyright holder, or other party has been advised of the possibility 
of such damages.