Recent

Author Topic: [SOLVED] Listview.ItemIndex - Linux port to Windows  (Read 848 times)

roger T

  • New Member
  • *
  • Posts: 14
[SOLVED] Listview.ItemIndex - Linux port to Windows
« on: July 13, 2024, 04:08:47 am »
I have the following code:-

procedure TSys1.ListViewClick(Sender: TObject);
   begin

   if(ListView.ItemIndex > -1) then
      begin
               do something
      end;

end;                 
           
Linux: A click on any column in a row returns the row index   
Windows: Only a column 1 click will return the row index

Am I able to have the Windows version working like the Linux version
« Last Edit: July 15, 2024, 04:48:24 am by roger T »

cdbc

  • Hero Member
  • *****
  • Posts: 1646
    • http://www.cdbc.dk
Re: Listview.ItemIndex - Linux port to Windows
« Reply #1 on: July 13, 2024, 07:43:34 am »
Hi
Did you remember to set 'ViewStyle' = 'vsReport'?!?
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

roger T

  • New Member
  • *
  • Posts: 14
Re: Listview.ItemIndex - Linux port to Windows
« Reply #2 on: July 13, 2024, 07:44:26 am »
Yes, I did

cdbc

  • Hero Member
  • *****
  • Posts: 1646
    • http://www.cdbc.dk
Re: Listview.ItemIndex - Linux port to Windows
« Reply #3 on: July 13, 2024, 07:50:04 am »
Hi
You could have, that given only the first column is an item and the rest are subitems, winders only returns the first one...
Sorry, unable to test, no winders here...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

dsiders

  • Hero Member
  • *****
  • Posts: 1282
Re: Listview.ItemIndex - Linux port to Windows
« Reply #4 on: July 13, 2024, 08:47:55 am »
I have the following code:-

Code: [Select]
procedure TSys1.ListViewClick(Sender: TObject);
begin

if(ListView.ItemIndex > -1) then
begin
               do something
end;

end;                 
           
Linux: A click on any column in a row returns the row index   
Windows: Only a column 1 click will return the row index

Am I able to have the Windows version working like the Linux version

I'm using Lazarus 3.99 (trunk).

It fires the OnClick event on WIndows when a subitem is clicked. It does not, however,  make the subitem selected because subitems never become selected on Windows.

If you want the same behavior on both Linux and Windows, Set RowSelect to True. The OnClick triggers when the row is clicked (no matter which item or subitem is clicked) and the entire row is highlighted.

I tested on Windows and QT6. Can't speak for GTK.
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

roger T

  • New Member
  • *
  • Posts: 14
Re: Listview.ItemIndex - Linux port to Windows
« Reply #5 on: July 13, 2024, 10:04:29 am »
Yup, that does the trick.
Interesting to note that it is false on the Linux version but still selects by row.

Cheers
Roger

P.S. Am I able to mark this as solved

dsiders

  • Hero Member
  • *****
  • Posts: 1282
Re: Listview.ItemIndex - Linux port to Windows
« Reply #6 on: July 13, 2024, 11:24:44 am »
P.S. Am I able to mark this as solved

Add the text "[SOLVED]" to the start od the subject line in your original post.
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

 

TinyPortal © 2005-2018