472,353 Members | 1,439 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

Listview select from Textbox string

I have a text box select items in a listview as text is being typed
into the text box. I get the select bar to move correctly in the
Listview control.

If the user presses the down or up key in the text box, I want to move
to the selected item in the listview box.

The down or up arrow does set focus to the listview box and the
selected item switches from the grey of being unfocused to the blue of
focus. So far, so good.

Pressing the down arrow again moves to the second entry in the
listview instead of the entry below the currently highlighted entry.
Susbsequent cursor movements work.

Obviously, the selected table index that I'm using is not working
correctly. What do I need to do to fix it?

Private Sub txtLoc_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles txtLoc.TextChanged
Dim boolFound As Boolean
Dim i As Integer
Dim intLen As Integer
Dim Item As ListViewItem
Dim strLoc As String

strLoc = txtLoc.Text.Trim ' Get the string
If strLoc = "" Or strLoc = Nothing Then Exit Sub
intLen = strLoc.Length ' Length of substring

For i = 0 To lvw.Items.Count - 1
Item = lvw.Items(i) ' Get the item
Try
If boolFound = False And Item.Text.Substring(0,
intLen) = strLoc Then
lvw.Items(i).Selected = True
lvw.Items(i).EnsureVisible()
boolFound = True
Else
lvw.Items(i).Selected = False
End If
Catch ex As Exception
lvw.Items(i).Selected = False
End Try
Next
End Sub

Private Sub txtLoc_KeyUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles txtLoc.KeyUp
If e.KeyData = Keys.Down Then lvw.Focus()
If e.KeyData = Keys.Up Then lvw.Focus()
End Sub

Thanks
Nov 20 '05 #1
1 3874
sorry
do you know how to print images which inside listview control??

"Shane" <sh***********@yahoo.com> wrote in message
news:4b**************************@posting.google.c om...
I have a text box select items in a listview as text is being typed
into the text box. I get the select bar to move correctly in the
Listview control.

If the user presses the down or up key in the text box, I want to move
to the selected item in the listview box.

The down or up arrow does set focus to the listview box and the
selected item switches from the grey of being unfocused to the blue of
focus. So far, so good.

Pressing the down arrow again moves to the second entry in the
listview instead of the entry below the currently highlighted entry.
Susbsequent cursor movements work.

Obviously, the selected table index that I'm using is not working
correctly. What do I need to do to fix it?

Private Sub txtLoc_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles txtLoc.TextChanged
Dim boolFound As Boolean
Dim i As Integer
Dim intLen As Integer
Dim Item As ListViewItem
Dim strLoc As String

strLoc = txtLoc.Text.Trim ' Get the string
If strLoc = "" Or strLoc = Nothing Then Exit Sub
intLen = strLoc.Length ' Length of substring

For i = 0 To lvw.Items.Count - 1
Item = lvw.Items(i) ' Get the item
Try
If boolFound = False And Item.Text.Substring(0,
intLen) = strLoc Then
lvw.Items(i).Selected = True
lvw.Items(i).EnsureVisible()
boolFound = True
Else
lvw.Items(i).Selected = False
End If
Catch ex As Exception
lvw.Items(i).Selected = False
End Try
Next
End Sub

Private Sub txtLoc_KeyUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles txtLoc.KeyUp
If e.KeyData = Keys.Down Then lvw.Focus()
If e.KeyData = Keys.Up Then lvw.Focus()
End Sub

Thanks

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Lauwers | last post by:
I know you can edit the first column of the listview control, is there a way to edit the second and/or the other columns? greets John
6
by: Vanessa | last post by:
With this program I can do one selection, but upon the second I get an error where ///////////////// is indicated. Please help. using System;...
0
by: Islam Elkhayat | last post by:
In my Application i search my Employee database and view result in List View with 3 column.. here is the code:...
3
by: MikeY | last post by:
Hopefully someone can help me on this. I am using C#, making Windows forms. I have created a listView with checkbox's. I have enabled the...
2
by: MikeY | last post by:
Hi all, I am coding window forms in C#. My problem is this: I have created a "Check ListView" or a 'ListView' with checkbox's. I have...
5
by: Matt Michael | last post by:
Hi, I'm having a problem working with a listview in an application I'm writing. Currently, whenever the selectedindex changed event fires, it...
2
by: Niels Jensen | last post by:
Hi all, I have a listview and a textbox. when I select a row in the listview I want to be able to click on the textbox and type in some details....
4
by: Bill-R | last post by:
I'm trying to convert a vb6 program to vb.net (vb2008 express) I have text data in a Listview Control I use a Textbox to enter characters to...
0
by: mesut | last post by:
Hi colleagues, I've a very strange problem here. I have no clue whyt it happens. I have a listview. The Listview populates well. I have an...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.