Solved

treeview node selection

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

9 Experts available now in Live!

Get 1:1 Help Now