Ask a Question

ListView - GetCell() method

SOLVED
OAn
Occasional Contributor

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.

1 ACCEPTED SOLUTION

Accepted Solutions
AlexKaras
Community Hero

Re: ListView - GetCell() method

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.htm... and related help topics for more details.

Hope this will help.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

7 REPLIES 7
AlexKaras
Community Hero

Re: ListView - GetCell() method

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?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
OAn
Occasional Contributor

Re: ListView - GetCell() method

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
Community Hero

Re: ListView - GetCell() method

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.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
OAn
Occasional Contributor

Re: ListView - GetCell() method

I did, Alex. The trouble is with the TextEventArgs parameter. For them is easy to define it with C#: they simply instantiate the class

ItemTextEventArgs tea = new ItemTextEventArgs(); From as far as I know, this cannot be done within TestComplete. In fact I couldn't find this object ItemTextEventArgs, starting from VList object. The closest object that seems to have something in common with ItemTextEventArgs() is cachedLayoutEventArgs, which is always (Null Object).
I'll keep on looking for.
AlexKaras
Community Hero

Re: ListView - GetCell() method

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.htm... and related help topics for more details.

Hope this will help.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

OAn
Occasional Contributor

Re: ListView - GetCell() method

I've finally succeed. It took more than a month to figure out how is working: with Alex's last suggestions I've reached dotNET node. But even from dotNET node is not easy to get the instance of ItemTextEventArgs, using TestComplete manual (https://support.smartbear.com/testcomplete/docs/app-testing/desktop/net/creating-class-instances.htm... which doesn't work with my tested application.

So, what does saved me was TestComplete message error, which was clear stated that it cannot convert the variable I was using to type 'Framework.UI.ItemTextEventArgs'. Later and by chance, I found this instances under dotNET node.

So, this is how the function should look like:

SelectedCellText:=ListViewdObj.GetCell(ListViewdObj.HeaderItems.Item[columnNo],lineNo,columnNo,Sys.Process('YourApplication').AppDomain('YourApplication.exe').dotNET.Framework_UI.ItemTextEventArgs.zctor(),'Excel');

and it works for me(with Delphi script and TestComplete 14.91.341.7 x64).

Now, SelectedCellText will be an object and the cell value will be SelectedCellText.OleValue

 

Thank you!

 

AlexKaras
Community Hero

Re: ListView - GetCell() method

Hi,

 

Thank you a lot for the update, detailed description and code sample provided!

Much appreciated indeed.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
cancel
Showing results for 
Search instead for 
Did you mean: