Recent

Author Topic: Sorting Listview  (Read 8935 times)

qwertaz

  • Newbie
  • Posts: 4
Sorting Listview
« on: February 03, 2012, 04:39:10 pm »
I am using ListView (vsReport) and I want to sort items (integer numbers) in 3rd column. How do I do it? Built-in doesn't work well.

JD

  • Hero Member
  • *****
  • Posts: 1907
Re: Sorting Listview
« Reply #1 on: February 03, 2012, 04:57:26 pm »
I asked a question concerning TListView's CustomSort here
http://lazarus.freepascal.org/index.php/topic,15260.msg81732.html#msg81732

I'm yet to get an answer.

Linux Mint - Lazarus 4.0/FPC 3.2.2,
Windows - Lazarus 4.0/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

typo

  • Hero Member
  • *****
  • Posts: 3051

qwertaz

  • Newbie
  • Posts: 4
Re: Sorting Listview
« Reply #3 on: February 03, 2012, 05:43:21 pm »
It might work, but I have problem since I want to sort 3rd column not 1st. I replaced 'Item1.Caption' to 'Item1.SubItems.Text', but it seems it gets data from wrong column. Another problem is that it works only one time, when I click on top of the column nothing changes. It would be great if I could sort ascending/descending.

BTW. Anyone know how to set default value in SpinEdit? I put 'SpinEdit1.Value:=10;' in OnCreate Form, but despite it says that is 10 procedure gets only 0.
« Last Edit: February 03, 2012, 05:49:36 pm by qwertaz »

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Sorting Listview
« Reply #4 on: February 03, 2012, 08:09:37 pm »
procedure TForm1.FormCreate(Sender: TObject);
begin
  SpinEdit1.Value:=10;
end;
Lazarus Trunk / fpc 2.6.2 / Win32

qwertaz

  • Newbie
  • Posts: 4
Re: Sorting Listview
« Reply #5 on: February 04, 2012, 01:31:43 pm »
@Avishai
That is exactly what I said and did, but another procedure that gets data from SpinEdit gets 0, not 10.

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Sorting Listview
« Reply #6 on: February 04, 2012, 02:38:07 pm »
I can not reproduce that.  Can you show some code?  It is difficult to know what is happening without it.
Lazarus Trunk / fpc 2.6.2 / Win32

qwertaz

  • Newbie
  • Posts: 4
Re: Sorting Listview
« Reply #7 on: February 04, 2012, 07:57:59 pm »
Nvm about SpinEdit. I was assigning value of SpinEdit to variable in OnChange event, that's why it didn't work.


 

TinyPortal © 2005-2018