Forum > LCL

[Resolved]TTreeView.Expand is protected, Why?

(1/2) > >>

jamie:
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?

ASerge:

--- Quote from: jamie 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.

--- End quote ---
Method TTreeNode.Expand(Recurse: Boolean) and property TTreeNode.Expanded are public.

jamie:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---protected procedure TCustomTreeView.Expand(    Node: TTreeNode  ); virtual; 

MarkMLl:
I don't claim to be an expert but no ptoblem here:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---                  if (thisTLIndex < OTHERS_) { and not Assigned(TreeViewSlips.Selected)    WHY ?????   } then                    TreeViewSlips.Items.TopLvlItems[thisTLIndex].Expand(false); 
MarkMLl

Remy Lebeau:

--- Quote from: jamie 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 ?

--- End quote ---

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.

Navigation

[0] Message Index

[#] Next page

Go to full version