How can Select multiple rows together in ListView

Class library usage, coding and language questions.
saurabh
Posts: 20
Joined: Fri Jul 20, 2007 1:11 pm
Location: India
Contact:

How can Select multiple rows together in ListView

Post by saurabh » Fri Jul 27, 2007 1:10 pm

I am trying to automate list view in my application and want to select multiple rows together to perform some opration but i am unable to do that it is selecting only one row at a time.Please guide me and send me the code for the same.
Thanks in Advance

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Fri Jul 27, 2007 4:25 pm

You can select multiple rows as follows

Code: Select all

ListView listView = form.FindListView("listView1");
if (listView != null)
{
    listView.Focus();
    Element row1 = listView.Element.FindChild(Role.ListItem, "item1");
    row1.Select(Selection.TakeSelection);

    Element row2 = listView.Element.FindChild(Role.ListItem, "item2");
    row2.Select(Selection.AddSelection);
}
Hope this helps!

Gabor
Ranorex Team

saurabh
Posts: 20
Joined: Fri Jul 20, 2007 1:11 pm
Location: India
Contact:

How to select mutiple rows by index

Post by saurabh » Mon Aug 20, 2007 9:15 am

Here the above code is working fine but problem is here that we can not select the two rows which have same text.Like if in a listview under a column ITEM there is row's text same like "item1" ,"item1" then i am unable to select both row together it will take only one row .So is there any facility so that i can select the row on the base of their index?Then i think confilction will not occure.So please tell me how can i select multiple row uniquely using index of listview.
Regards,
Saurabh Shrivastava
GE Global Research
Bangalore India

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Tue Aug 21, 2007 10:14 pm

...row's text same like "item1" ,"item1" then i am unable to select both row together it will take only one row
You can select all rows with the text "item1" as follows:

Code: Select all

Element[] items = listView.Element.FindChildren(Role.ListItem,"item1");
foreach(Element item in items)
{
    item.Select(Selection.AddSelection);
}
Jenö
Ranorex Team