Solved

treeview node selection

Posted on 2001-07-07
5
151 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
searching for DavidI's "Mobile Summer School download" 3 128
Path  to current project in Delphi. 2 71
Delphi XE10 Round Image 2 75
How to debug For loops? 3 45
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

948 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now