Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6179995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:46:05+00:00 2026-05-24T00:46:05+00:00

There is a Tree View with 2 levels of items. I need to add

  • 0

There is a Tree View with 2 levels of items. I need to add a text of all selected “sub” (level 1) items into a Memo.

for i := 0 to pred(TreeView1.Items.count) do 
if (TreeView1.Items.Item[i].Selected) and (TreeView1.Items.Item[i].Level=1)
   then 
       begin
            Memo1.Lines.Add(TreeView1.Items.Item[i].Text)
       end;

But how to add all the “sub” items at once without their checking (selected or not) if their parent (level 0) is selected? E.g. I select the 3 items with the level 0 and their children are added into the Memo.

Thanks for help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:46:07+00:00Added an answer on May 24, 2026 at 12:46 am

    Only get level 1 nodes which have a selected parent:

    var
      Node: TTreeNode;
      Sub: TTreeNode;
    begin
      Node := TreeView.Items.GetFirstNode;
      while Node <> nil do
      begin
        if Node.Selected then
        begin
          Sub := Node.GetFirstChild;
          while Sub <> nil do
          begin
            Memo1.Lines.Add(Sub.Text);
            Sub := Sub.GetNextSibling;
          end;
        end;
        Node := Node.GetNextSibling;
      end;
    end;
    

    Update due to comment:

    Get level 1 nodes which have a selected parent, or are selected themselves:

    var
      I: Integer;
    begin
      for I := 0 to TreeView.Items.Count - 1 do
        with TreeView.Items[I] do
          if (Level = 1) and (Selected or Parent.Selected) then
            Memo1.Lines.Add(Text);
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a treeview which contains, per node, a key and text. However, there
There is an very old WPF application of Hyper Tree - http://blogs.msdn.com/b/llobo/archive/2007/10/31/mindmap-app-using-hyperbolic-tree.aspx . The
Is there a C# Library to generate a decision tree from a datatable and
Is there an easy way to compare the file tree of an old git
How to prune decision tree build with ID3 when there are too few examples
Is there a built-in data structure in Java to represent a Crit-bit tree? Or
Is there a way to organize the roles in my app like a tree?
Is there a way without using extra space to find LCA of nary tree.
Is there a way to do the following ? I have a tree item
I know there is the ExpandableListView but it only supports up to 2 levels.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.