Accessing SysListView32 and ListViewItems with Ranorex 2.0

Ask general questions here.
SamC
Posts: 4
Joined: Thu Nov 27, 2008 4:55 am

Accessing SysListView32 and ListViewItems with Ranorex 2.0

Post by SamC » Thu Nov 27, 2008 5:04 am

Using Ranorex Spy I can correctly locate the SysListView32 control and its' child items, but I would like to know how to programmatically:

1. Iterate the list of all ListItems by index rather than name.
2. Access the subitem text in addition to the detail 0'th item text value which is displayed by default in the Spy.

Thank you.

Sam.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Thu Nov 27, 2008 10:18 am

The ListView class provides the GetItemText(int index, int subItem) method that allows you to get the text of listview (sub)items. index is the index of the item, subItem the index of the subitem (zero corresponding to the item text if not in detail mode).

Use one of the Control.FindListView(...) overloads to get the listview directly or create it from a control:

Code: Select all

ListView listView = new ListView(listViewControl.Handle);
Regards,
Alex
Ranorex Support Team

SamC
Posts: 4
Joined: Thu Nov 27, 2008 4:55 am

Post by SamC » Thu Nov 27, 2008 7:03 pm

HI Alex,

Sorry for the confusion, I'm using 2.0 Preview and I don't see a ListViewControl. There is the new List and ListItem, but I can't seem to get either of those to do what I would like.

Thanks.

Sam.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Fri Nov 28, 2008 10:02 am

I'm sorry, I thought you were using Ranorex 1.5 - my fault!

The List and ListItem adapters in Ranorex 2.0 Preview are not finished, yet. In the final Ranorex 2.0 version the List adapter will provide an Items property that returns it's items as ListItem instances.

Currently, with the preview there are two ways to iterate through the item with index:
1. Use indeces in the path, e.g. "/pathToList/listitem[1]" (one-based index).
2. Use the list adapter's internal element to iterate the children (zero-based index):

Code: Select all

List list = "/pathToList";
ListItem listItem = list.Element.Children[2].As<ListItem>();
Regards,
Alex
Ranorex Support Team

SamC
Posts: 4
Joined: Thu Nov 27, 2008 4:55 am

Post by SamC » Fri Nov 28, 2008 7:29 pm

Thanks for the info, I'll give this a try.

Can you also explain how I can get to the Subitem text of the ListItem control?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Mon Dec 01, 2008 9:14 am

If the treeview is in Detail view, it will have the Table role. It's children are then rows and columns and the cells of the rows/columns are the subitems of the listview.

Regards,
Alex
Ranorex Support Team

SamC
Posts: 4
Joined: Thu Nov 27, 2008 4:55 am

Post by SamC » Sat Dec 06, 2008 8:13 pm

Hi Alex,

I'm confused by your reference to a treeview control, I'm trying to access the ListItem and subitems of a List control.

If your saying there is a way to coerce a Table reference from the List, can you please give an example?

Thanks.

Sam.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Tue Dec 09, 2008 8:58 am

Sorry, I meant listview instead of treeview in my previous posting, was a typo.

If the listview is in detail mode, Ranorex will interpret it as a table. You can see that using Ranorex Spy on a SysListView32 control in detail mode (e.g. Windows Explorer). Each list item is represented by a row, each sub item by a cell in the corresponding row.

So, if the list is in detail mode, just use the Table adapter instead of the List:

Code: Select all

Table listViewInDetailMode = "/pathToListView";
The Table adapter is not finished, yet, the next preview version will provide easy-to-use properties to get the rows and cells from a table.

Regards,
Alex
Ranorex Support Team

osaighi
Posts: 10
Joined: Thu Mar 25, 2010 10:44 am

Re: Accessing SysListView32 and ListViewItems with Ranorex 2.0

Post by osaighi » Thu Mar 25, 2010 11:22 am

Hello,

I have the same problem but i cannot access to my listview control like a table. When i use RanorexSpy it recognize the listview control like a list control, so i cannot access to the subitems.

Do you have a workaround?


Thank You

Using Ranorex 2.2

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Accessing SysListView32 and ListViewItems with Ranorex 2.0

Post by Support Team » Thu Mar 25, 2010 1:26 pm

Hi,

Are you using the .Net ListView?
Because when you use a SysListView32 you will get a table (Row and Cells) from Ranorex Spy. But if you have implemented the ListView from .Net you will get ListItems of a List Control. So at the moment there is no other way to access the items of a .Net ListView.

Regards,
Peter
Ranorex Support Team
.
Image

osaighi
Posts: 10
Joined: Thu Mar 25, 2010 10:44 am

Re: Accessing SysListView32 and ListViewItems with Ranorex 2.0

Post by osaighi » Thu Mar 25, 2010 2:28 pm

In case this a .Net listview how can I access to the subitems of my listitems ?

osaighi
Posts: 10
Joined: Thu Mar 25, 2010 10:44 am

Re: Accessing SysListView32 and ListViewItems with Ranorex 2.0

Post by osaighi » Thu Mar 25, 2010 2:53 pm

My listview control is a basic win32 control but i cannot use it like a table with ranorex, someone know why?

How can i do to force it?

Thank you

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Accessing SysListView32 and ListViewItems with Ranorex 2.0

Post by Support Team » Thu Mar 25, 2010 7:39 pm

osaighi wrote:How can i do to force it?
There is no way to "force" that. If the control is a SysListView32 and it is in "Detail" style, Ranorex will recognize it as a Table and present its data as cells in rows and columns.

Could you please post a Ranorex snapshot of your application and of that control? See the corresponding User Guide topic on how to create Ranorex snapshots:
http://www.ranorex.com/support/user-gui ... html#c2072

By the way, which Ranorex version do you use?

Regards,
Alex
Ranorex Support Team
.
Image

osaighi
Posts: 10
Joined: Thu Mar 25, 2010 10:44 am

Re: Accessing SysListView32 and ListViewItems with Ranorex 2.0

Post by osaighi » Fri Mar 26, 2010 11:04 am

Hi,

Here you have the attachments of application snapshot and the listview control snapshot :
Application.rxsnp
(133.35 KiB) Downloaded 208 times
ListViewControl.rxsnp
(12.35 KiB) Downloaded 203 times
I'm using the 2.2 Ranorex Version.

Thank you

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Accessing SysListView32 and ListViewItems with Ranorex 2.0

Post by Support Team » Fri Mar 26, 2010 12:53 pm

Hi,

first thanks for the snapshots. I've wrote a little test application of your problem, but I cannot reproduce your problem. Is it possible, that you post a little sample application with the same list you are using in your Main App.
One question, what apperance view is set to your list. Report, Icon, SmallIcon or List?

Regards,
Peter
Ranorex Support Team
.
Image