Recent

Author Topic: [Resolved]TTreeView.Expand is protected, Why?  (Read 293 times)

jamie

  • Hero Member
  • *****
  • Posts: 6556
[Resolved]TTreeView.Expand is protected, Why?
« on: September 07, 2024, 07:08:40 pm »
I need to expand a TreeNode and apparently someone thought it was a good idea to protect it.

How am I supposed to directly expand a Node in the tree via code then?

I cannot find an alternative to this.

I suppose I could perform a local hack to expose it but why?

It is virtual which leads to me to believe its there somewhere?

« Last Edit: September 07, 2024, 08:37:22 pm by jamie »
The only true wisdom is knowing you know nothing

ASerge

  • Hero Member
  • *****
  • Posts: 2321
Re: TTreeView.Expand is protected, Why?
« Reply #1 on: September 07, 2024, 07:27:39 pm »
I need to expand a TreeNode and apparently someone thought it was a good idea to protect it.
Method TTreeNode.Expand(Recurse: Boolean) and property TTreeNode.Expanded are public.

jamie

  • Hero Member
  • *****
  • Posts: 6556
Re: TTreeView.Expand is protected, Why?
« Reply #2 on: September 07, 2024, 07:59:03 pm »
Expand accepts a Node. which indicates that it must expand at that node.

Did I miss something ?

Code tools does see it but the compiler does not.
Code: Pascal  [Select][+][-]
  1. protected
  2.  
  3. procedure
  4.  TCustomTreeView.Expand(
  5.  
  6.  
  7.   Node: TTreeNode
  8.  
  9.  
  10. );
  11.  virtual
  12. ;
  13.  
The only true wisdom is knowing you know nothing

MarkMLl

  • Hero Member
  • *****
  • Posts: 7633
Re: TTreeView.Expand is protected, Why?
« Reply #3 on: September 07, 2024, 08:16:08 pm »
I don't claim to be an expert but no ptoblem here:

Code: Pascal  [Select][+][-]
  1.                   if (thisTLIndex < OTHERS_) { and not Assigned(TreeViewSlips.Selected)    WHY ?????   } then
  2.                     TreeViewSlips.Items.TopLvlItems[thisTLIndex].Expand(false);
  3.  

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1408
    • Lebeau Software
Re: TTreeView.Expand is protected, Why?
« Reply #4 on: September 07, 2024, 08:21:42 pm »
Expand accepts a Node. which indicates that it must expand at that node.

Did I miss something ?

Yes, you are. You are looking at the TCustomTreeView.Expand() method, which is indeed protected on the TreeView itself.  You should instead be using an individual node's TTreeNode.Expand() method or TTreeNode.Expanded property, which are both public.
« Last Edit: September 07, 2024, 08:24:31 pm by Remy Lebeau »
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

jamie

  • Hero Member
  • *****
  • Posts: 6556
Re: TTreeView.Expand is protected, Why?
« Reply #5 on: September 07, 2024, 08:36:55 pm »
Expand accepts a Node. which indicates that it must expand at that node.

Did I miss something ?

Yes, you are. You are looking at the TCustomTreeView.Expand() method, which is indeed protected on the TreeView itself.  You should instead be using an individual node's TTreeNode.Expand() method or TTreeNode.Expanded property, which are both public.

Ok, Sorry, my mistake.

Thanks for the heads up.
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018