Recent

Author Topic: TListView set selected item  (Read 22863 times)

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: TListView set selected item
« Reply #15 on: February 11, 2016, 04:46:13 pm »
Tried above demo with my old Laz 1.4.0 (32-bit) installation on Win-7 64bit. Running fine (i.e. only one of both methods needed).

Is your Lazarus the 32-bit or 64-bit version? If 64-bit install the 32-bit as a secondary installation, 64-bit does not have a real advantage for most programs, but faces you with several disadvantages (debugger).

balazsszekely

  • Guest
Re: TListView set selected item
« Reply #16 on: February 11, 2016, 05:33:45 pm »
@wp
Your test project works fine.
@PeterX
Please attach a simple application that demonstrates the issue, otherwise we just shot in the dark.

PeterX

  • Sr. Member
  • ****
  • Posts: 404
Re: TListView set selected item
« Reply #17 on: February 11, 2016, 10:19:43 pm »
Hello GetMem,

I think about extracting the whole code of the Tree+ListView as a
separate component - to make it usable in more than this current application.
I will start working on this tomorrow.
If the mysterious behaviore still occurs there, I'll post again.

But read back the whole thread. Other people also said
that it didn't work for them .. and this is years ago, it's a really old thread.


But it's true, without example code You will not be able to
reproduce this behaviore :-(

=> I will start working on this tomorrow.
« Last Edit: February 11, 2016, 10:22:29 pm by PeterX »
usually using latest Lazarus release version with Windows 10

PeterX

  • Sr. Member
  • ****
  • Posts: 404
Re: TListView set selected item
« Reply #18 on: February 11, 2016, 10:21:53 pm »
Is your Lazarus the 32-bit or 64-bit version?

I never use the 64 bit version.
32 bit must be enough ;-)
usually using latest Lazarus release version with Windows 10

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: TListView set selected item
« Reply #19 on: February 12, 2016, 12:07:12 am »
I think about extracting the whole code of the Tree+ListView as a
separate component - to make it usable in more than this current application.
It may be less work to learn how to use VirtualTreeView, it combines a tree with a grid (which looks like a listview in report style), and it is an excellent component which is even used in commercial applications. See http://wiki.lazarus.freepascal.org/VirtualTreeview and http://wiki.freepascal.org/VirtualTreeview_Example_for_Lazarus (but there are also more detailed turorials for Delphi)

PeterX

  • Sr. Member
  • ****
  • Posts: 404
Re: TListView set selected item
« Reply #20 on: February 12, 2016, 09:51:51 am »
Hm, the VirtualTreeview looks very interesting.

I am not in a hurry so I maybe go both ways.
Keeping my program running is the main goal.


But first I will try wp's  "Listview_Selected.zip" code
to find out how it should work and why it doesn't in my app.
usually using latest Lazarus release version with Windows 10

PeterX

  • Sr. Member
  • ****
  • Posts: 404
Re: TListView set selected item
« Reply #21 on: February 12, 2016, 10:21:31 am »
Okay, wp's  "Listview_Selected.zip" code works for me.

Then I tried again my project ..  %)


As this is an old Delphi project of mine,
(written between 2000 and 2004 ..)
I converted it with the Lazarus conversion tools.
As there are several differences between LCL and VCL,
lots of code didn't work as intended.

The last days I edited a lot of code and .. however, this
Code: [Select]
ListView.ItemIndex:= i;works now !   :)

I only wonder why MY selection is BLUE
and the selection in wp's  "Listview_Selected.zip" code is light GRAY ?
usually using latest Lazarus release version with Windows 10

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: TListView set selected item
« Reply #22 on: February 12, 2016, 10:46:22 am »
I only wonder why MY selection is BLUE and the selection in wp's  "Listview_Selected.zip" code is light GRAY ?
This is only a matter of focus. If the listview is focused then the selection is blue, otherwise it's gray. Just TAB through the controls on your form and see that the selection becomes blue only if the focus is at the listview (If the listview is the only control on the form then, of  course, the selection will always be blue).

PeterX

  • Sr. Member
  • ****
  • Posts: 404
Re: TListView set selected item
« Reply #23 on: February 12, 2016, 11:23:18 am »
Resolved now !

Thanks for all Your help and suggestions !
usually using latest Lazarus release version with Windows 10

 

TinyPortal © 2005-2018