Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Focus to an Item in ListView C# 3.5 Compact

Posted on 2009-07-04
5
Medium Priority
?
2,723 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 48

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 2000 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 48

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

885 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