Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TTreeView selecting top nodes?

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
0
0
Alright, so I've got this tree view that is always expanded. Can't collapse. And it's kind of in the format of:

+Category1
-Subitem1
-Subitem2
-Subitem3
+Category2
-Subitem1
-Subitem2
-Subitem3

For some reason, maybe just stupidity, I can't for my life seem to be able to catch the selected category when a user double clicks it. I tried selected but instead of showing me the selected category, it lists the selected subitems. The categories can be dynamically added and removed by the user so I can't hardcode in anything. I'm not exactly sure what the problem is--you'd think i'd be simple enough but I just can't get that 'Selected' to work.

Cyprus
 
Dear cyprus106,
I had a looong chat with my treeview in the beginning of using bcb5.

I got it working and let me just collect some ideas I have:

(MTV is mytreeview, MTN mytreenode, ok?)

MTV->AutoExpand = false; // should let You collapse all

When I use any ttreenode, and want it selected after a doubleclick, then I wrote a MTV->OnChange Handler
where I change a pagecontrol and set the

TTreeNode *MTN = MTV->Selected;
MTN->Selected = true;

MTN can be Category or Subitem, no problem.
I have done the same for a rightclick handler, works fine, too.
And You said something about topnode:
MTV->TopItem = MTN; // should work, maybe You set the MTV->Selected->Selected = true; // afterwards

Maybe this helps?
otherwise I will try to post more code.

Best regards,
Michael


... Welladay! Welladay!
For the winds of May!
Love is unhappy when love is away!
-excerpt,see my profile- James Joyce,1907
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top