Solved

Selected TreeView??

Posted on 1998-04-01
7
1,246 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
  • 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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 50 total points
ID: 1184011
if ((TreeView1->Selected)->Text== "Business Operation Agreements") {
     RichEdit1->Text = "yes";
}
else {
     RichEdit1->Text = "no";
}
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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…
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 learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

706 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now