Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HELP TIWTreeView
#1
I'm really struggling her without any help resource - where can I get help for TIWTreeView ?  I try using VCL techniques but I get errors like undefine TTreeNode (or TIWTreeNode) and if I busk my way past that I get AddChild is not a member of TIWTreeViewItems
Reply
#2
Hi Denville, see this demo in IW15.
Reply
#3
(04-17-2019, 01:53 PM)Jose Nilton Pace Wrote: Hi Denville, see this demo in IW15.

Thanks for the reply.  Being a c++ man Pascal is a bit obscure to me - nevertheless, using the demo code and peeking at the .hpp file I am now able to create a sub-node..

        TIWTreeViewItem* tnp = LogTreeView->Items->Add( NULL, Node_text );

                    LogTreeView->Items->Add( tnp, Subnode_text );

However the main node is displayed expanded with the sub-nodes all visible; clicking on the + or - has no effect, and this is the case regardless of whethrer I set tnp->Expanded to false, true, or leave it alone.  I need it to start not expanded and expand when the user clicks on + !

Also, I implemented the TreeItemClick event but nothing seems to fire this - I notice that it is not designate an Async event, I also noticed the AsyncMode property and tried this True and (default) false, but with no success.

Denville.


Attached Files Thumbnail(s)
   
Reply
#4
Denville,

It sounds like your tree isn't constructed properly.  With all of that stuff not working... (as opposed to just a piece not working that could be something smaller)

My (Delphi) treeview code looks like this:

Code:
ProjectTree.ClearAll;

// loop through studies and reports.  Studies are parents to reports
lStudyNode := ProjectTree.Items.Add( nil );
lStudyNode.Caption := 'a Study Caption';
lStudyNode.Expanded := false;

lReportNode := ProjectTree.Items.Add( lStudyNode );
lReportNode.Caption := 'a Report Caption';
// stop looping

Then I set the overall on click for the tree nodes like this:
ProjectTree.TreeItemClick         := ProjectTreeTreeItemClick;

If you set DoServerSidePlusMinus, you'll get the onPlusMinus event fired when you click the plus/minus.  Otherwise it will only occur client side. If you've got DoServerSidePlusMinus set to false, and your nodes aren't opening and closing, you're probably missing JS code somehow. (or you've overridden CSS maybe?)

Your code looks right to me.  (Same as mine but the caption is set in the Add() method.  But if stuff looks corrupted, check to make sure you're not reusing tnp or other nodes you're creating incorrectly.  For a test, maybe create them with static code rather than using a loop.  And use different variables for the nodes to be sure you're not stomping on existing pointers.  Also, you can build the tree in the designer.  That would enable you to see if they open/close and allow selection properly before you try to create it at run-time.

Hope that helps,
Pete
Reply
#5
(04-17-2019, 11:00 PM)pete@pdmagic.com Wrote: Denville,

It sounds like your tree isn't constructed properly.  With all of that stuff not working... (as opposed to just a piece not working that could be something smaller)

My (Delphi) treeview code looks like this:

Code:
ProjectTree.ClearAll;

// loop through studies and reports.  Studies are parents to reports
lStudyNode := ProjectTree.Items.Add( nil );
lStudyNode.Caption := 'a Study Caption';
lStudyNode.Expanded := false;

lReportNode := ProjectTree.Items.Add( lStudyNode );
lReportNode.Caption := 'a Report Caption';
// stop looping

Then I set the overall on click for the tree nodes like this:
ProjectTree.TreeItemClick         := ProjectTreeTreeItemClick;

If you set DoServerSidePlusMinus, you'll get the onPlusMinus event fired when you click the plus/minus.  Otherwise it will only occur client side. If you've got DoServerSidePlusMinus set to false, and your nodes aren't opening and closing, you're probably missing JS code somehow. (or you've overridden CSS maybe?)

Your code looks right to me.  (Same as mine but the caption is set in the Add() method.  But if stuff looks corrupted, check to make sure you're not reusing tnp or other nodes you're creating incorrectly.  For a test, maybe create them with static code rather than using a loop.  And use different variables for the nodes to be sure you're not stomping on existing pointers.  Also, you can build the tree in the designer.  That would enable you to see if they open/close and allow selection properly before you try to create it at run-time.

Hope that helps,
Pete

Hi, thanks.  OK, a number of things have occurred, specifically..
(1) - I had a drive failure following which I have a brand new ssd with new installation of W7/64 fully up to date.  I installed XE7 C++ Builder (update 1), opting not to install IW.  Then I ran the IW bundled removal tool which said it was successful but some files were left which should be removed manually( unfortunately it didn't say which).  Then I installed latest IW (.20), and allowed it to run the unbundle tool again.
Now I built a new IW project with just a button and a treeview.  The result was EXACTLY as before in every respect.
(2) I forked out and updated my license which had apparently expired in late 2018 (how time flies) and installed the new key.  Now, the 'evaluation' problem seems to have gone away - great.  But...

I am left with the original TreeView problem - nothing about it seems to work.  This is the code in its entirety...

static TIWTreeViewItem *tnp, *snp;

void __fastcall TIWForm1::IWButton2AsyncClick(TObject *Sender, TStringList *EventParams)
///////////////////////////////////////////////////////////////////////////////////////
{
    tnp = LogTreeView->Items->Add( NULL );
    tnp->Caption = "First Node";

    snp = LogTreeView->Items->Add( tnp );
    snp->Caption = "First Sub Node";

    tnp->Expanded = false;
}

void __fastcall TIWForm1::LogTreeViewTreeItemClick(TObject *Sender, TIWTreeViewItem *ATreeViewItem)
//////////////////////////////////////////////////////////////////////////////////////////////////
{
String us = ATreeViewItem->Caption;

us = us;
}

Just as before, the TV displays expanded with the + and - ineffective, and (double) clicking on one or t'other fails to fire the Click event.  I have tried setting AsyncMode (default True) to both T and F, and setting DoServerSidePlusMinus (default True) set both T and F.  I added the following code with no success:

void __fastcall TIWForm1::LogTreeViewPlusMinus(TObject *aSender, bool aIsPlus)
/////////////////////////////////////////////////////////////////////////////
{
    tnp->Expanded = aIsPlus;
}

Please, what have I missed ?

Denville.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)