Board index » cppbuilder » How to change the Text of TTreeNode in TTreeView::onEdited and TTreeView::onEditing

How to change the Text of TTreeNode in TTreeView::onEdited and TTreeView::onEditing

Hi,

I have a TTreeView with nodes that have a Text that is composed out of
multiple values. When the user now wants to change the text of the
TTreeNode, I want to remove some of the data from the Text because the user
is not allowed to edit it. After the user is ready I want to put the text
back.

I tried to program in the TTreeView::onEditing the following code:

            Node->Text = lName.getCString().c_str();
            lTreeView->Update();

So that I update the Text of the TTreeNode, but then in the edit box the
user gets inside the tree still the old Text is shown. A call to Update() or
Invalidate() also doesn't help.

Can someone give me info what I do wrong or is it not possible?

Johnny

 

Re:How to change the Text of TTreeNode in TTreeView::onEdited and TTreeView::onEditing


Use the OnEdited event instead of OnEditing.  When OnEdited is triggered,
the Node->Text hasn't been updated yet, so you still have access to the old
value.  The S parameter of the event handler contains the user's new input.
You can then modify S as needed.  Whatever value is assigned to S when the
event handler is exited will be the new value assigned to the Node->Text.
You can't change the Node->Text yourself directly, as it will be overriden
automatically.

Gambit

Quote
"Johnny Willemsen" <jwillem...@remedy.nl> wrote in message

news:3d732f22$1@newsgroups.borland.com...
Quote
> I have a TTreeView with nodes that have a Text that is
> composed out of multiple values. When the user now
> wants to change the text of the TTreeNode, I want to
> remove some of the data from the Text because the
> user is not allowed to edit it. After the user is ready I
> want to put the text back.

Other Threads