--- bobby <[EMAIL PROTECTED]> escribió:
> I have StringGrid with 3 Columns: source file (with path), target
> (path)
> and errors
> where:
> source file column contains files to copy
> target column contains target folders
> errors column contains return errors : 0-if copy suceed, 1-copy
> didn't
> succeed, 2-source file don't exist
>
> Now, after operations finish, I want to have all the rows with
> greater
> error number on the top of the StringGrid.
>
> If I use StringGrid1.SortColRow(true, 2) I get funny results, but
> the
> rows with the errors are not on the top.
>
> Thanks for any advice
>
Don't know what version do you have, some days ago a patch was
submited that implements by default ascending sorting based on string
comparision, previously all comparision returned 0, ie assume that
all strings are equal, in this circustances the sort algorithm still
swap some rows and that's why you may see funny jumping results after
repeated sorting.
But if you want custom sorting (descending) there are some
alternatives;
a. Create an handler for StringGrid's OnCompareCells event, something
like this:
procedure TForm1.StringGrid1CompareCells(Sender: TObject; Acol, ARow,
Bcol,
BRow: Integer; var Result: integer);
begin
// Compare strings
result := CompareText(StringGrid1.Cells[ACol,ARow],
StringGrid1.Cells[BCol,BRow]);
// if you want to compare integers instead of
// strings so '1','3','11' are correctly sorted:
// result :=
StrToIntDef(StringGrid1.Cells[ACol,ARow],0)-StrToIntDef(StringGrid1.Cells[BCol,BRow],
0);
// suppose that there is a checkbox that enables
// descending sorting, do something like this
if Checkbox1.checked then
Result := -Result;
end;
b. Install SemaphorGrid (examples/grid_semaphor) afaik, it also
implements sorting with several options.
Jesus Reyes A.
___
Do You Yahoo!?
La mejor conexión a Internet y 2GB extra a tu correo por $100 al mes.
http://net.yahoo.com.mx
_
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives