?
Solved

Sortable Item/Value List Component

Posted on 2004-10-13
9
Medium Priority
?
256 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
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!

 

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 200 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month11 days, 19 hours left to enroll

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