Solved

Sortable Item/Value List Component

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

Technology Partners: 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

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…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 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