Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TStringAlignGird - Can I Sort on more than 1 column

Status
Not open for further replies.
Jan 15, 2010
1
ZA
Hi Guys,

I have made progress in attempting to sort the TStringAlignGrid using multiple columns. I am able to hold down ctrl key and capture that column name into a tStringList. The string values from these columns are concatenated/copied into a "Sort" column and then i want to sort on that column. However i am seperating each value from each column with a ',' and padding them with 5 zero's. When the code to sort the grid run's, the sorting is inaccurate.

I thought i would post only the part where the copying and concatenating of the values are taking place. The values are transfered to a "Sort" column. The sort code is then executed but the results of the sorting are inaccurate.

for index := 0 to sColumnList.Count - 1 do
begin
sColumn := sColumnList.Strings[index];

for c := 0 to sag.ColCount - 1 do
begin
if sColumn = sag.Cells[c,0] then
begin
for r := 2 to sag.RowCount - 1 do
begin
sag.Cells[SortCol, r] := sag.Cells[SortCol, r] + '00000';

sValue := sag.Cells[c, r] + ',';
sag.Cells[SortCol, r] := sag.Cells[SortCol, r] + sValue;
end;
end;
end;

end;

sag.SortColumn(SortCol, bAscending);

When i copy these values (from the sort column) into excel, it sorts correctly.

Has anyone done a sort on more than 1 column in a TStringAlignGrid before? Pls help.






 
Perhaps you need to trim blank values that are being processed by the sorting function but don't appear in the grid.

Code:
sValue := trim(sag.Cells[c, r]) + ',';
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top