?
Solved

treeview node selection

Posted on 2001-07-07
5
Medium Priority
?
160 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
nnbbb09 earned 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 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