highvoltagerd
asked on
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??
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??
ASKER
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.
-=- James.
ASKER
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->Delet e();
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->GetHitTestInfoA t(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->MoveT o(pItem, AttachMode);
}
__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->Delet
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(
{
if (Source != (TObject *)TreeView1 || TreeView1->Selected == NULL)
return;
THitTests HT = TreeView1->GetHitTestInfoA
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->MoveT
}
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.
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.
ASKER
I looked and can only find index numbers to link to graphics (to display the graphic next to the node).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
-=- James.