TTreeview Parent

Hi,
 I am using a ttreeview component.
 I have many parent nodes each of which
 has four child nodes. My question is
 how can I determine the parent node
 of each child in a way that will not
 produce an exception if the selected
 item is the parent. I am able to
 get the parent when a child node is
 selected, however, if you have the
 parent already selected, the program
 (index) produces an exception. I don't
 really understand ttreeview. Can anyone
 help. (Sorry for rambling!).
 Thanks,
 Michael
mmcgurlAsked:
Who is Participating?
 
intheConnect With a Mentor Commented:
Hi
usE the haschildren one:

with GetNodeAt(X, Y) do begin
    Selected := True;
    if HasChildren then ...;
  end;
 
0
 
rwilson032697Commented:
Hmmm..

You can check if the parent is assigned like this:

  If Assigned(ANode.Parent) then
    // Do something with the parent

Is this what you want?

Cheers,

Raymond.


0
 
LischkeCommented:
Barry,

you answered so fast, it seems you have understood the question. I haven't so please you explain it for me (because I doubt your answer has anything to do with what's asked, but I may be wrong).

Michael,

as you see from my comment fro Barry I have not understood what you want. So I'm just guessing here. Can it be that you want the parent of the selected node and access properties of it (the parent) without ever testing whether the parent is valid? It isn't as hard as it might seem sometimes. If you can formulate your problem then you almost have the solution. Believe me, I have enhanced Delphi's tree view (see TreeNT at www.lischke-online.de) and am currently writing a totally own tree implementation (TVirtualTree). If you have further question then just ask, we can work it out :-)

Ciao, Mike
0
 
LischkeCommented:
Aha
0
 
intheCommented:
well, seems i must have understood  ;-)
0
All Courses

From novice to tech pro — start learning today.