Recent

Author Topic: Set VirtualDrawTree checkbox to True using code  (Read 1122 times)

JD

  • Hero Member
  • *****
  • Posts: 1848
Set VirtualDrawTree checkbox to True using code
« on: November 15, 2020, 02:13:14 pm »
Hi there everyone,

I am trying to set checkboxes in a VirtualDrawTree's nodes to True using code IF a certain string is found in one of the node's columns.

Here is part of a procedure I wrote to achieve this objective:

Code: Pascal  [Select][+][-]
  1.     //intItems := 0;
  2.     //
  3.     repeat
  4.       if XNode = nil then
  5.         XNode := ATree.GetFirst
  6.       else
  7.         XNode := ATree.GetNext(XNode);
  8.  
  9.       //Inc(intItems);
  10.       Data := ATree.GetNodeData(XNode);
  11.  
  12.       if Data^.Column[2] = AWord then
  13.         //ShowMessage('Check row ' + IntToStr(intItems));
  14.         ATree.CheckState[XNode] := csCheckedNormal;
  15.     until XNode = ATree.GetLast();
  16.     ATree.Invalidate;
  17.  

The problem is that this does not work at all. The code finds the string in the node's column 2 but the node is not checked at all.

What am I doing wrong?

Thanks for your assistance.

JD
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

balazsszekely

  • Guest
Re: Set VirtualDrawTree checkbox to True using code
« Reply #1 on: November 16, 2020, 09:43:50 am »
Hi JD,

Once I wrote a VDT exemple for another forum user. You can find in the attachement, a slightly modified version of that example, where checksupport is added. You can also search, then check a specific node.

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: Set VirtualDrawTree checkbox to True using code
« Reply #2 on: November 19, 2020, 11:50:29 am »
Hi JD,

Once I wrote a VDT exemple for another forum user. You can find in the attachement, a slightly modified version of that example, where checksupport is added. You can also search, then check a specific node.

Thank you so much GetMem.  :D

JD
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

 

TinyPortal © 2005-2018