Solved

Focus to an Item in ListView C# 3.5 Compact

Posted on 2009-07-04
5
2,510 Views
1 Endorsement
Last Modified: 2013-11-17
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

1
Comment
Question by:novabankaee
  • 3
  • 2
5 Comments
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 24779100
The best you will be able to do is make the item visible by using the EnsureVisible method -> http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.ensurevisible.aspx

Wayne
0
 

Author Comment

by:novabankaee
ID: 24779148
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;
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 24779157
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.
0
 

Author Comment

by:novabankaee
ID: 24779194
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
0
 

Author Closing Comment

by:novabankaee
ID: 31599879
Thansk a lot Wayne
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question