Forum Discussion

OAn's avatar
OAn
Contributor
4 years ago

ListView - GetCell() method

Hi,

 

I'm using TestComplete Version: 14.90.432.7 x64 with DelphIScript. The tested application is developed with C#.

Does anyone used GetCell method for a ListView control? The function format get it from Object Spy is: function GetCell(Framework.UI.HeaderItem; line : Integer; column : Integer; Framework.UI.ItemTextEventArgs; PrintContext : SystemString) : System.String;

While I did figured the first three parameters, for the last two(Framework.UI.ItemTextEventArgs; PrintContext : SystemString) I cannot see where can I find them, they are not straightforward methods within ListView Object Spy.

 

I can give you a clue from a similar method function for the same control, which is GetCellNumericValue(Framework.UI.HeaderItem; line : Integer; HeaderIndex: Integer; bWasException : ref System.Boolean) : Real; I have successfully used this one and indeed returns only a number: for instance, if you use it on a ListView column with strings, it will return value 0, while for a column with numbers, it return the number at the specified position within ListView's table.

A real example is this one: ListViewdObj.GetCellNumericValue(ListViewdObj.HeaderItems.Item[4],2,4,False);

 

Thank you.

  • Hi,

     

    > they simply instantiate the class ItemTextEventArgs tea = new ItemTextEventArgs(); 

    Generally speaking, the same is possible in TestComplete:

    -- You need to add the assembly that implements the ItemTextEventArgs class to the CLR Bridge as well as all required dependent assemblies;

    -- After that in the code completion window under dotNET node you should see the assembly, class name, its constructor (named as .zctor() ) and all other public methods provided by the class.

    Depending on your scripting language you should be able to write the code like this:

    var iteaClass = dotNET.<assembly>.ItemTextEventArgs.zctor();

    and use created class instance in your code.

     

    See https://support.smartbear.com/testcomplete/docs/app-testing/desktop/net/creating-class-instances.html and related help topics for more details.

    Hope this will help.

     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    or the last two [...] I cannot see where can I find them

    Just a wild guess: what if you pass nil for these last two parameters?

     

    • OAn's avatar
      OAn
      Contributor

      Thank you, Alex. It doesn't like it. It will throw an "Unknown error". In fact I've tried quite a few combinations and this is the most "friendly" error I could get.

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        Any chance to talk to developers and ask them for the code sample in C# ?

        Considering that the tested application in in C# and thus is accessible to TestComplete, I would expect that it will be possible to port their sample into DelphiScript.