Solved

Focus to an Item in ListView C# 3.5 Compact

Posted on 2009-07-04
5
2,454 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now