how can i select multiple row using index of listview

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

how can i select multiple row using index of listview

Post by saurabh » Tue Aug 21, 2007 11:31 am

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

chall
Posts: 15
Joined: Mon Aug 20, 2007 4:15 pm

Post by chall » Tue Aug 21, 2007 9:33 pm

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);
}
}

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

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

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

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

I want to use Item index to select rows

Post by saurabh » Wed Aug 22, 2007 6:12 am

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
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 » Wed Aug 22, 2007 9:05 am

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