Solved

Focus to an Item in ListView C# 3.5 Compact

Posted on 2009-07-04
5
2,547 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

735 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