tommykjensen
asked on
stringgrid sorting
I have a stringgrid in the gui.
How do I sort all the rows when clicking on one of the collumn titles?
How do I sort all the rows when clicking on one of the collumn titles?
ASKER
Does anybody have an example? I am relatively new to Delphi.
I have Dellphi 6 proff. Soon I will have V7.
I have Dellphi 6 proff. Soon I will have V7.
ASKER
Does anybody have an example? I am relatively new to Delphi.
I have Dellphi 6 proff. Soon I will have V7.
I have Dellphi 6 proff. Soon I will have V7.
ASKER
Found a solution. How do I close this question?
HI,
You can do it for example that way:
procedure TForm1.BitBtn1Click(Sender : TObject);
var SL: TStringList;
begin
SL:=TStringList.Create;
with StringGrid1 do
begin
SL.Assign(Rows[1]);
SL.Sort;
Rows[1].Assign(SL);
end;
SL.Free;
end;
Sincerely,
Nestorua.
You can do it for example that way:
procedure TForm1.BitBtn1Click(Sender
var SL: TStringList;
begin
SL:=TStringList.Create;
with StringGrid1 do
begin
SL.Assign(Rows[1]);
SL.Sort;
Rows[1].Assign(SL);
end;
SL.Free;
end;
Sincerely,
Nestorua.
Dear expert(s),
A request has been made to close this Q in CS:
https://www.experts-exchange.com/questions/20556426/Please-refund-points-I-solved-my-problem-myself.html
Without a response in 72 hrs, a moderator will finalize this question by:
- Saving this Q as a PAQ and refunding the points to the questionner
When you agree or disagree, please add a comment here.
Thank you.
modulo
Community Support Moderator
Experts Exchange
A request has been made to close this Q in CS:
https://www.experts-exchange.com/questions/20556426/Please-refund-points-I-solved-my-problem-myself.html
Without a response in 72 hrs, a moderator will finalize this question by:
- Saving this Q as a PAQ and refunding the points to the questionner
When you agree or disagree, please add a comment here.
Thank you.
modulo
Community Support Moderator
Experts Exchange
np
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
But if it isn't you have to do it yourself.
I dont have the time right now to do a sample, but the idea is to write out the column to a TSTringList and sort i there.
All other data in the same row are also written to a tstringlist (or similar) and saved in the first tstringlist with TStringList.AddObject('Dat
Sort the stringlist - clear the grid - write data back to the grid.
Good luck
Peter