Solved

Selected TreeView??

Posted on 1998-04-01
7
1,264 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
Technology Partners: 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 50 total points
ID: 1184011
if ((TreeView1->Selected)->Text== "Business Operation Agreements") {
     RichEdit1->Text = "yes";
}
else {
     RichEdit1->Text = "no";
}
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C Language combined operators 28 123
PDF library for Delphi 2 135
Safe conversion? 4 76
VS2015 Redefinition errors 4 91
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…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

726 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