• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 363
  • Last Modified:

stringgrid sorting

I have a stringgrid in the gui.

How do I sort all the rows when clicking on one of the collumn titles?
0
tommykjensen
Asked:
tommykjensen
  • 3
  • 2
  • 2
  • +1
1 Solution
 
PeterLarsenCommented:
I dont remember for sure, but i think this function is included in delphi 6 or 7.

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('Data to be sorted', Pointer-to-the-second-TStringList).
Sort the stringlist - clear the grid - write data back to the grid.


Good luck
Peter
0
 
tommykjensenAuthor Commented:
Does anybody have an example? I am relatively new to Delphi.

I have Dellphi 6 proff. Soon I will have V7.
0
 
tommykjensenAuthor Commented:
Does anybody have an example? I am relatively new to Delphi.

I have Dellphi 6 proff. Soon I will have V7.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
tommykjensenAuthor Commented:
Found a solution. How do I close this question?
0
 
nestoruaCommented:
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.
0
 
moduloCommented:
Dear expert(s),

A request has been made to close this Q in CS:
http://www.experts-exchange.com/Community_Support/Q_20556426.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
0
 
PeterLarsenCommented:
np
0
 
moduloCommented:
Saving this Q as a PAQ and refunding the points to the questionner

Thanks PeterLarsen !

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now