Solved

Sortable Item/Value List Component

Posted on 2004-10-13
9
233 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

23 Experts available now in Live!

Get 1:1 Help Now