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 9120941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:44:38+00:00 2026-06-17T05:44:38+00:00

I ran into a discrepancy with indexes of nodes in a tree view. This

  • 0

I ran into a discrepancy with indexes of nodes in a tree view. This tree has only 2 levels of hierarchy, a number of root nodes and a number of nodes under each of those. When I read TTreeView.Selected.Index, I get the index of the root node only, but when I read TTreeView.Items[TTreeView.Selected.Index] (iterating in a loop), I get a completely different tree node.

A more specific example, suppose I have this data:

  • Root 1
    • Item 1.1
    • Item 1.2
    • Item 1.3
  • Root 2
    • Item 2.1
    • Item 2.2
    • Item 2.3
  • Root 3
    • Item 3.1
    • Item 3.2
    • Item 3.3

Now suppose I select “Root 3” and read TTreeView.Selected.Index, it will return 2. However, when I read TTreeView.Items[2] it returns “Item 1.2” because it’s really the third item in the list. The one I have selected “Root 3” is index number 8 in reality.

What would be the correct way to read the index of the currently selected root node so I get 8 instead of 2?

  • 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-06-17T05:44:39+00:00Added an answer on June 17, 2026 at 5:44 am

    TTreeNode.Index is relative to TTreeNode.Parent. TTreeView.Items[] uses absolute indexes, so use TTreeNode.AbsoluteIndex instead. However, Items[Selected.AbsoluteIndex] is redundant and inefficient, as it returns the same TTreeNode that Selected returns.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ran into this problem today, posting in case someone else has the same issue.
Ran into this error message while trying to select some records off a table.
Ran into this while converting a VB.NET interface to C#; the VB version defines
I ran into this error, and found very little documentation on how to fix
I ran into a small problem using Python Regex. Suppose this is the input:
I ran into this example for locking Windows workstation: using System.Runtime.InteropServices; ... [DllImport(user32.dll, SetLastError
I ran into a weird behavior from Oracle this morning... And I can't understand
I ran into a problem this week regarding implicit conversions in C# on collections.
Ran into a little problem and I'm not entirely sure why this code won't
I ran into this issue earlier in the week and again just now. I'm

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.