Forum > LCL

Test the object type of TTreeNode.Data

(1/1)

Marion:
How do I determine the object type in a TTreeNode.Data?

I have tried and failed with:


--- 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";}};} ---TypeOf(Node.Data^) = TypeOf(TProject) Node.Data = TypeOf(TProject)
I can't find anything about this.

jamie:
First you need to check it for assignment...

if Assigned(Node.Data) then
 
 if TObject(Node.Data) is TheNameOFTheClass Then....

Marion:

--- Quote from: jamie on May 05, 2021, 10:50:34 pm ---First you need to check it for assignment...

if Assigned(Node.Data) then
 
 if TObject(Node.Data) is TheNameOFTheClass Then....

--- End quote ---


Thank you so much!

Remy Lebeau:

--- Quote from: jamie on May 05, 2021, 10:50:34 pm ---First you need to check it for assignment...

if Assigned(Node.Data) then

--- End quote ---

You don't need that.  All that will do is tell you whether Data is nil or not.  Calling the 'is' operator on a nil pointer will return False (and likewise, calling the 'as' operator on a nil pointer will return a nil pointer).  So the Assigned() check is redundant.

Navigation

[0] Message Index

Go to full version