Forum Discussion

ecstansel's avatar
ecstansel
New Contributor
6 years ago

Need assistance with TVirtualStringTree Headers/Columns

Hello,

 

I am working with the TVirtualStringTree class. Our application implements this class to mimic a multi-column list box, meaning that the class has headers enabled w/ columns, and every item or node in each column does not have any children.

 

See the attachment for an example.

 

I've mapped the TVirtualStringTree under the Win32 => Tree View class, and this has worked so far, but it is only looking at the first column. I need to be able to somehow designate the column, and then click on one of the nodes.

 

Here is the example code I have, which will only work with the first column in the object. How can I go about selecting Item 3 and Item 4 in the picture?

 

variablePickListTree.SelectItem("|Item1");

variablePickListTree.SelectItem("|Item2");

 

 

5 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    Try recording a test where you select each of the items and see what TestComplete gives you.  Recording is good for finding out what TestComplete is actually calling an object.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Ah... TVirtualStringTree... how I loathe thee... ;)

     

    Back in the day I tested a desktop application coded in Delphi that had a LOT of those built into it.   The problem with the TVirtualStringTree is that the tree nodes in the string tree are Delphi record types... they are not OLE compatible data types so you can't get to the nodes using standard TestComplete functions and methods like SelectItem or ClickItem.  You lucked out that SelectItem at least works for the first column... that doesn't always work, though, depending upon how the tree is implemented.

     

    IIRC (and it's been at least 7 years since I've last worked with this component), in our implementation of the TVirtualStringTree, it was wrapped with additional components that allowed for searching and/or filtering of the contents of the string tree which allowed us to use other methodology to find and select the records we wanted.  No, it was not EXACTLY interacting with the component as is, but our goal was not to test the component but to test the functionality of the application that used the component so those work arounds worked for us.

     

    So... my advice to you is to investigate your application to see if there is some other way to select the nodes/columns you want in your component and write some helper script code that you can call regularly to click on those columns.

     

    alternatively, get in touch with your developers and see if they can build in some hidden helper functions directly into the application that are only present for your automation build.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    OK... I did some research and I found a couple of old threads.

     

    Specifically, this one https://community.smartbear.com/t5/TestComplete-Functional-Web/TC-8-60-and-TVirtualTreeView-GetNodeLevel/td-p/71516 seems to have the most practical help in implementing something with the TVirtualTreeView.  

     

    You can also look up https://community.smartbear.com/t5/TestComplete-Functional-Web/Delphi-VCL-Object-TStatusBar-and-TVirtualStringTree-TChart/td-p/70894