|
-
Nov 5th, 2003, 09:45 AM
#1
Thread Starter
New Member
Selecting an item in ListView
I have a text box for the user to enter an id number. The user then clicks on a button and if a matching number is found in the id field of the listView, that item becomes selected. Any ideas how I do this??
-
Nov 5th, 2003, 11:31 AM
#2
what do you mean by "id field of the listView"? is it the text of the list item the id?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Nov 5th, 2003, 11:42 AM
#3
Thread Starter
New Member
Sorry, didn't explain very well. The database I'm using has a field called ID which is a number. How do I select the record in the ListView by clicking on a button.
Hope that makes a bit more sense??
-
Nov 6th, 2003, 12:40 AM
#4
well you could use something like this to find the index of the item... only if the ID is the text of the listview item, and only if its the first colum... you can probably change this a bit to make it work for your code. I dont think .NET itself provides a way to search:
VB Code:
Public Shared Function ListViewFind(ByVal txt As String, ByVal lvw As ListView) As Integer
Dim li As ListViewItem
For Each li In lvw.Items
If li.Text = txt Then
Return li.Index
End If
Next
Return -1
End Function
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Nov 6th, 2003, 06:43 AM
#5
Thread Starter
New Member
Thanks for the code. I can now get the index. As you've probably guessed I'm a newbie!
So is there any way I can use this index to automatically select the item in the listview??
Thanks in advance.
-
Nov 6th, 2003, 10:21 AM
#6
Thread Starter
New Member
Think I've cracked it at last:
Me.ListView1.Items.Item(intIndex).Selected = True
Thanks for your help MrPolite.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|