Solved

Sortable Item/Value List Component

Posted on 2004-10-13
9
245 Views
Last Modified: 2010-04-05
Hi,
Is there a value list component that would support clickable column name to sort (asc, desc) on that column? Also it will need to be able to support this setup:

Name       Price
Item1       $1
Item2       $2

etc...

When I click Item1, I want the whole row to be highlighted. There has got to be something like this already out there....
Thanks!
0
Comment
Question by:maxb
[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
  • 5
  • 4
9 Comments
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 12302775
What about, a normal ListView?

Set the following properties for the ListView:
ReadOnly - True
RowSelect - True
ViewStyle - vsReport

Add the columns you want, add the data you want.

Then, add OnColumnClick handler



var
  SortOrder: Integer;

function CustomSortProc(Item1, Item2: TListItem;
  ParamSort: Integer): Integer; stdcall;
var
  s1, s2: string;
begin
  if ParamSort = 0 then
  begin
    s1 := Item1.Caption;
    s2 := Item2.Caption;
  end else
  begin
    s1 := Item1.SubItems[0];
    s2 := Item2.SubItems[0];
  end;
  Result := CompareText(s1, s2) * SortOrder;
end;

procedure Form1.ListView1ColumnClick(Sender: TObject;
  Column: TListColumn);
begin
  SortOrder := SortOrder * -1;
  ListView1.CustomSort(@CustomSortProc, Column.Index);
end;
0
 

Author Comment

by:maxb
ID: 12302826
That would wok except I would like those little sort tirangles next to the columns to point up or down.
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 12302871
Ah, I was wondering how to do that too, some time ago (4 years ago, actually), and Barry answered it... check it out http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_11054223.html
0
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!

 

Author Comment

by:maxb
ID: 12302908
Ah, it sounds like this solution will give me a 14px indentation on all the items? Is there really no component that can do this cleanly?
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 12303114
0
 

Author Comment

by:maxb
ID: 12303158
wow...total overkill but cool looking.... still searching for a solution....
0
 
LVL 14

Accepted Solution

by:
DragonSlayer earned 50 total points
ID: 12303250
or what about these...

VirtualTreeView by Mike Lischke http://www.delphi-gems.com/VirtualTreeview/VT.php (free)
Advanced ListView http://www.tmssoftware.com/advlistv.htm (USD65)
TKStringGrid http://www.korzh.com/delphi/components/ (free)
TPubStrGrid http://www.micrel.cz/delphi/index_e.html#jbstrgrd (free)

I have used the first 3 before, and would recommend the first one (Mike's VT), but it's learning curve is a bit more steep than the rest. You might want to check out TKStringGrid too.
0
 

Author Comment

by:maxb
ID: 12304457
TKStringGrid rocks, thank you!!
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 12305074
no probs, glad I could've helped!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Making delphi communicate with a c# service 16 123
Firemonkey android show image from resource ? 1 56
Delphi and Access based Enumeration 9 78
Broadcast a message using ICS 2 25
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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