?
Solved

stringgrid sorting

Posted on 2003-03-15
8
Medium Priority
?
361 Views
Last Modified: 2010-04-04
I have a stringgrid in the gui.

How do I sort all the rows when clicking on one of the collumn titles?
0
Comment
Question by:tommykjensen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 2

Expert Comment

by:PeterLarsen
ID: 8143881
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
 

Author Comment

by:tommykjensen
ID: 8145766
Does anybody have an example? I am relatively new to Delphi.

I have Dellphi 6 proff. Soon I will have V7.
0
 

Author Comment

by:tommykjensen
ID: 8145816
Does anybody have an example? I am relatively new to Delphi.

I have Dellphi 6 proff. Soon I will have V7.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:tommykjensen
ID: 8146126
Found a solution. How do I close this question?
0
 
LVL 4

Expert Comment

by:nestorua
ID: 8147039
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
 

Expert Comment

by:modulo
ID: 8170463
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
 
LVL 2

Expert Comment

by:PeterLarsen
ID: 8172291
np
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 8186436
Saving this Q as a PAQ and refunding the points to the questionner

Thanks PeterLarsen !

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question