Solved

treeview node selection

Posted on 2001-07-07
5
155 Views
Last Modified: 2010-04-06
my question is how can i select the last parent node entered without selecting a childnode?
0
Comment
Question by:moggy12
  • 2
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
nnbbb09 earned 50 total points
ID: 6262166
Hello,

Try this. It works by starting with the last node in the treeview and working its way back to the first one. As soon as it find's a node with no parent it selects it and breaks out of the loop.

procedure TForm1.Button1Click(Sender: TObject);
var
  i:integer;
begin
  for i:=treeview1.items.count -1 downto 0 do
  begin
    if treeview1.items[i].parent=nil then
    begin
      treeview1.items[i].Selected:=true;
      break;
    end;

  end;
end;

Jo
0
 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6263756
I see you didnt accept nnbbb09 comment therfore I have a question:

as you see nnbbb09 comment finds the Last root ( or node without parent ) made in the treeview and I Think this  comment is acceptable.therefor maybe we dont understand your exact question. now what is your main question?
0
 

Author Comment

by:moggy12
ID: 6263991
Thanks nnbbb09, you answer gave me what i was looking for.

mohsenian, i was busy elsewhere and i think it rude of you that you assume that if someone does not respond back promptly they have rejected the answer.    
0
 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6264222
hi moggy12,

sorry, you are right but I think 'rude' is not a good word for my action.
0
 

Author Comment

by:moggy12
ID: 6269483
what word would you use then..."arrogant",
"obnoxious"...or do you have one in mind?

I hope you will give others a little more time before jumping on them.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Working this component WebCopy with proxy, help 3 100
How to debug For loops? 3 60
How to load 2 images in same column in Delphi 2 67
Breakpoint doesn't stop in my variable 3 36
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question