Solved

Sortable Item/Value List Component

Posted on 2004-10-13
9
236 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
  • 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now