Page 1 of 1

how can i select multiple row using index of listview

Posted: Tue Aug 21, 2007 11:31 am
by saurabh
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.

Posted: Tue Aug 21, 2007 9:33 pm
by chall
Perhaps you can do something like this:

int numOfItems = listView.ItemCount;
for (int i = 0; i < numOfItems; i++)
{
string itemName = listView.GetItemText(i, 0);
if (itemName.Equals("item1"))
{
listView.SelectItem(itemName);
}
}

Posted: Tue Aug 21, 2007 10:33 pm
by webops
Or 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

I want to use Item index to select rows

Posted: Wed Aug 22, 2007 6:12 am
by saurabh
I have used this approach,But my problem is different.Like I have 10 rows in ListView now I want to select 3rd,5th and 7th row from there.Now might be in 3rd and 5th row the value will be same for the Column ITEM like "item1" so in this case it will select only 5th and 7th row because we are using ITEM column as a unique key.My idea that I don't want to use any column as a unique In ListView there is ItemIndex which is starting form 0,1,2,3,4,5,6,7,8,9 for 10 rows I want to use this ItemIndex value to select rows.Becuase this would be always unique so there will be no confilction between two rows.I think now you can understand my problem.Please provide me solution for the same as soon as possible because its very critical.Thanks in Advance

Posted: Wed Aug 22, 2007 9:05 am
by webops
You can use index as follows:

Code: Select all

// Read all items of the ListView
Element[] items = listView.Element.FindChildren(Role.ListItem);

// Select item with index 5 and 7
items[5].Select(Selection.AddSelection);
items[7].Select(Selection.AddSelection);
Jenö
Ranorex Team