Selected TreeView??

I am using Borland C++ Builder v3.0 Standard edition and I tried the following codes to see what the current TreeView node is selected.

if (TreeView1->Selected == "Business Operation Agreements") {
 RichEdit1->Text = "yes";
else {
 RichEdit1->Text = "no";

But it didn't work.  My RichEdit1 just said no.

any reasons??
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

  Hmmm...  I do not know Borland OWL stuff, but are you sure that the "Selected" variable (function?) contains/returns the text of the selected item, not the HTREEITEM of the node selected?

-=- James.
highvoltagerdAuthor Commented:
Yip it is the correct function..  That is what the help files says.  But help is not to helpful!
  What do your help files read as far as return values from the "Selected" function or variable.

-=- James.
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

highvoltagerdAuthor Commented:
Specifies the selected node in the tree view.

__property TTreeNode* Selected = {read=GetSelection, write=SetSelection};


Read Selected to access the selected node of the tree view. If there is no selected node, the value of Selected is NULL.

Set Selected to set a node in the tree view. When a node becomes selected, the tree view's OnChanging and OnChanged events occur. Also, if the specified node is the child of a collapsed parent item, the parent's list of child items is expanded to reveal the specified node. In this case, the tree views OnExpanded and OnExpanding events occur as well.

Note:      If the RightClickSelect property is true, the value of Selected is the last node that was clicked in the tree view, even if it was clicked with the right mouse button.  This may differ from the node that is highlighted to indicate selection.

The following code deletes the selected item in the tree view.


The following code uses GetNodeAt to add a dragged node as a child of the node under then mouse when it is dropped.

void __fastcall TForm1::TreeView1DragDrop(TObject *Sender, TObject *Source, int X, int Y)

  if (Source != (TObject *)TreeView1 || TreeView1->Selected == NULL)
  THitTests HT = TreeView1->GetHitTestInfoAt(X, Y);
  TNodeAttachMode AttachMode;
  TTreeNode *pItem = TreeView1->GetNodeAt(X, Y);
  if (HT.Contains(htOnItem) || HT.Contains(htOnIcon))
    AttachMode = naAddChild;
  else if (HT.Contains(htNowhere))
    AttachMode = naAdd;
  else if (HT.Contains(htOnIndent))

    AttachMode = naInsert;
  TreeView1->Selected->MoveTo(pItem, AttachMode);
  Just as I thought, it returns pointer to a "TTreeNode" (whatever that is..).  I would think that when you insert items into the Tree, you would get a "TTreeNode" pointer to reference it by.

   You need to figure out how to get the text of the selected item from the "TTreeNode" pointer returned by "Selected" (be sure to check for NULL first!).  Once you have the text, you can compare it with your search key.

  PS: Ever got the rich edit thing working...? :P

-=- James.
highvoltagerdAuthor Commented:
I looked and can only find index numbers to link to graphics (to display the graphic next to the node).
if ((TreeView1->Selected)->Text== "Business Operation Agreements") {
     RichEdit1->Text = "yes";
else {
     RichEdit1->Text = "no";

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.