Link to home
Start Free TrialLog in
Avatar of novabankaee
novabankaee

asked on

Focus to an Item in ListView C# 3.5 Compact

Hello,
I have a ListView control and I fill a ListView through SortedList. I need, when I put word or part of a word in text box and click Search button to find word in sorted list, get it's index and  to jump to specific row (Item) in ListView with searched index. In compact framework I don't have TopItem properties so I need another way to scroll to specific row in ListView.
I also need that searched row would be on top row in ListView or at least in second or third row.

Thanks
//sl-SortedList; myListView_SelectedIndexChanget event
txtValue.Text = sl.GetByIndex(myListView.SelectedIndices[0].ToString())

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of novabankaee
novabankaee

ASKER

Yes that is the right method for me Wayne.
I need that row to be on top of the ListView but I get Item at the bottom of the ListView.
I get selected row grayed with:
myListView.Item[myindex].Selected = true;
As I said, the EnsureVisible method is as good as you are going to get.

Although, you could try making the last item visible, then calling the EnsureVisible method to get your selected item visible. This should make it display near the top of the ListView.
I use EnsureVisible twice.
First myListView.EnsureVisible(maxindex - 1) as you said and second with searched index I get Item on the Top.
Thanks a lot Wayne
Thansk a lot Wayne