SortAStringGrid V1.2.0

New in version 1.2.0:
- Added Date sort
- Changed errorcode -2
- Added errorcodes -3 and -4

New in version 1.1.2:
- Resources compiled as 32bit
- Changed numerical check from integer to real to allow for non-integers to
  be sorted correctly.
- added errorcode -2

Here is the filelist that is included in this archive

First the component files :
sasg.pas      Delphi Component Source file (Yes it is included)
sasg.dcr      Delphi Component Recourses
sasg.dcu      Delphi Component Unit
sasg.txt      The textfile you are reading now

Then the demo files :
sgt_u1.dfm    Delphi Form Module of the demo
sgt_u1.pas    Source of the demo
sgt.dpr       Delphi project file (This is the file you open in Delphi)
sgt.res       Resources for the project

By the way you can only compile the demo after you installed the component.

This component makes it easy to sort a StringGrid (Anyway you like). And what's
best : IT IS FREEWARE !!! No registration, No fees, No royalties, NOTHING.

But, I would like to hear from YOU, the user of my component. So please send me
an e-mail. My address is : sasg@jagodfried.demon.nl

To install the TSortAStringGrid component follow the guidelines of your version
of Delphi.

A new Component tab will be created call JG (Those are my initials) and it will
contain the component SortAStringGrid. (Doesn't that look easy) Since the
sourcefile is included you could change this to whatever you like but please
remember : if you change the component name, also change the bitmap name in the
sasg.dcr file !

Now let's go on to the interesting stuf. Properties and Methods.

First the properties :

GridToSort    You can doubleclick in the Object Editor to get the name
              of the stringgrid you want to sort. (If you have
              multiple stringgrids, you might have to doubleclick
              multiple times)
SortIndex     Column or Row that contains the sortkey
StartIndex    First Column or Row to be sorted
EndIndex      Last Column or Row to be sorted
SortType      Can be Character, Numeric or Date. If you have a grid filled
              with numbers and you sort them as characters, then 9
              would be greater than 1000. So if you choose Numeric,
              1000 will be greater then 9.
CaseSensitiv  If SortType is Character, you can set this property to true or
              false to enable or disable case sensitivity.
SortDirection Can be Ascending or Descending.
HowToSort     Can be Row or Column. This is a bit confusing but I
              will try to explain which does what.
              Suppose whe have the following grid :

               D A C B      And SortIndex  := 1,
               B C A D      StartIndex := 1,
               A B D C      EndIndex   := 4
               C D B A

              After a Sort with HowToSort := Row the grid will look
              like this (Sorted from Top to Bottom Row)

               A B D C
               B C A D
               C D B A
               D A C B

              After a Sort with HowToSort := Column the grid will look
              like this (Sorted from Left to Right Column)

               A B C D
               C D A B
               B C D A
               D A B C

ShowMessageOnError   If there occurs an error, you will get a message (using
                     MessageDlg) if this property is set to True.

                     There are two ways to find out what error has occured
                     for the programmer. The first way is via the run-time
                     variable ErrorCode. The second way is via the run-time
                     variable ErrorText. The ErrorCode has 3 groups :
                            - less then 0 : Warning. Sort will continue using valid
                                            settings.
                            - 0 : All is OK.
                            - greater then 0 : Error. No sort can be done.
                            Here are the codes and the text that belongs to them :

    Code   Text
    ====   ====================================================================
     -4    Case Sensitivity ignored for Date Sort.
     -3    Case Sensitivity ignored for Numeical Sort. (Was -2)
     -2    Column/Row contains non-date values for date sort. Sorted as
           Character.
     -1    Column/Row contains non-numerical values for numeric sort. Sorted as
           Character.
      0    Ok
      1    No StringGrid given
      2    StartIndex is greater or equal to EndIndex
      3    StartIndex is less then 0
      4    StartIndex is greater then number of rows/columns in StringGrid
      5    EndIndex is greater then number of rows/columns in StringGrid
      6    Sort Index is less then 0
      7    Sort Index is greater then number of rows/columns in StringGrid

And of course two standard properties : Name and Tag

Comming to the methods, well actualy it is just one method : Execute.
This method starts the sort and returns true if the ErrorCode is less then or
equal to 0. Otherwise it returns false.

So much for the textfile. I am sorry to say that there is no Helpfile that is
connected to the Delphi Help system but, uuuhhh let's just say that I was a bit
lazy. Maybe next time.

Have fun.
Greetinx


Johan Godfried. (The author from the Netherlands)