Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Selected TreeView??

Posted on 1998-04-01
7
Medium Priority
?
1,292 Views
Last Modified: 2008-02-01
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??
0
Comment
Question by:highvoltagerd
[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
  • 3
  • 3
7 Comments
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1184005
  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.
0
 

Author Comment

by:highvoltagerd
ID: 1184006
Yip it is the correct function..  That is what the help files says.  But help is not to helpful!
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1184007
  What do your help files read as far as return values from the "Selected" function or variable.

-=- James.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:highvoltagerd
ID: 1184008
Specifies the selected node in the tree view.

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

Description

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.

TreeView1->Selected->Delete();

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)
    return;
  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;
  else
    return;
  TreeView1->Selected->MoveTo(pItem, AttachMode);
}
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1184009
  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.
0
 

Author Comment

by:highvoltagerd
ID: 1184010
I looked and can only find index numbers to link to graphics (to display the graphic next to the node).
0
 
LVL 3

Accepted Solution

by:
q2guo earned 200 total points
ID: 1184011
if ((TreeView1->Selected)->Text== "Business Operation Agreements") {
     RichEdit1->Text = "yes";
}
else {
     RichEdit1->Text = "no";
}
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

598 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