Recent

Author Topic: How to implement readonly checkboxes in TreeView  (Read 565 times)

maurobio

  • Full Member
  • ***
  • Posts: 156
How to implement readonly checkboxes in TreeView
« on: December 16, 2019, 09:31:57 pm »
Dear ALL,

Is there a way to have a TreeView with node checkboxes disabled such that the user cannot check the checkboxes but can still click the symbol to open the treeview up?

Thanks in advance for any assistance you can provide.

Best regards,
UCSD Pascal / Burroughs 6700 / Master Control Program
Lazarus 1.9.3/2.0.8 - FPC 3.0.4 on GNU/Linux Mint 19 ("Tessa"), Windows XP SP3, Windows 7 Professional, Windows 10 Home

wp

  • Hero Member
  • *****
  • Posts: 7553
Re: How to implement readonly checkboxes in TreeView
« Reply #1 on: December 16, 2019, 10:14:28 pm »
By default, TTreeView does not show checkboxes, you must either owner-draw the nodes with checkboxes or you can use the StateImageList and the StateIndex to assign checked and unchecked images to the nodes -- IIRC there was a related discussion here recently, search the forum.

Since the checkboxes are under your control you can decide whether they can be changed by the user or not, it depends on how you implement them.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

soerensen3

  • Full Member
  • ***
  • Posts: 211
Re: How to implement readonly checkboxes in TreeView
« Reply #2 on: December 16, 2019, 10:23:47 pm »
If they do not need to be changed maybe you can use icons in an iconlist and use image index to control checked status.
Lazarus 1.9 with FPC 3.0.4
Target: Manjaro Linux 64 Bit (4.9.68-1-MANJARO)

maurobio

  • Full Member
  • ***
  • Posts: 156
Re: How to implement readonly checkboxes in TreeView
« Reply #3 on: December 16, 2019, 11:27:22 pm »
@wp, @soerensen,

Thanks, I got it. It's easy indeed.

Cheers,
UCSD Pascal / Burroughs 6700 / Master Control Program
Lazarus 1.9.3/2.0.8 - FPC 3.0.4 on GNU/Linux Mint 19 ("Tessa"), Windows XP SP3, Windows 7 Professional, Windows 10 Home

 

TinyPortal © 2005-2018