3 Replies - 418 Views - Last Post: 03 February 2012 - 06:42 AM Rate Topic: -----

Topic Sponsor:

#1 pathllk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 26-July 11

Scroll Listview items by text box

Posted 03 February 2012 - 02:31 AM

At first I am totaly new VB Net. In my project I Three textboxes and a listview. I can find the items of listview by 1st textbox change event. The codes are as given below:-
Private Sub sealv_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sealv.TextChanged
        Dim i As Integer
        For i = 0 To LV1.Items.Count - 1
            LV1.Items(i).BackColor = Color.White
        Next
        With LV1
            lst = .FindItemWithText(sealv.Text, True, 0, True)
            If Not lst Is Nothing Then
                .Items.Item(lst.Index).EnsureVisible()
                .Items.Item(lst.Index).BackColor = Color.YellowGreen
            Else
                For i = 0 To LV1.Items.Count - 1
                    LV1.Items(i).BackColor = Color.White
                Next
                .Items.Item(0).EnsureVisible()
                .Items.Item(0).BackColor = Color.YellowGreen
            End If
        End With
        lst = Nothing
    End Sub



Now, I want to learn the followings:-
1) How to scroll the listview items by textbox keyDown and KeyUp event.
2) And I want to get the listview focused item in the 2nd and 3rd textbox by 1st textbox keypress event( Enter press on keyboard).

Please help me regarding the above.

Is This A Good Question/Topic? 0
  • +

Replies To: Scroll Listview items by text box

#2 Ozzy18  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 04-October 11

Re: Scroll Listview items by text box

Posted 03 February 2012 - 02:33 AM

UMm fascinating stuff. I can do it though, I'm a pro , i'm currenlty studying at Cambridge =]

Do you want some help then ?
Was This Post Helpful? 0
  • +
  • -

#3 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 67
  • View blog
  • Posts: 522
  • Joined: 21-December 11

Re: Scroll Listview items by text box

Posted 03 February 2012 - 05:02 AM

Quote

1) How to scroll the listview items by textbox keyDown and KeyUp event.


first you must set up some listview properties:
HideSelection=false
MultiSelect=false
    Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
        If e.KeyCode = Keys.Down Then
            Try
                Dim selIndex As Integer = ListView1.SelectedItems(0).Index
                ListView1.Items(selIndex + 1).Selected = True
                ListView1.EnsureVisible(selIndex + 1)
            Catch
            End Try
        End If
    End Sub


Quote

2) And I want to get the listview focused item in the 2nd and 3rd textbox by 1st textbox keypress event( Enter press on keyboard).

    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
        Try
            TextBox2.Text = ListView1.SelectedItems(0).Text.ToString
        Catch
        End Try
    End Sub


Was This Post Helpful? 0
  • +
  • -

#4 pathllk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 26-July 11

Re: Scroll Listview items by text box

Posted 03 February 2012 - 06:42 AM

Dear sela007, I am using VB8 and your code not working for me. Please Help
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1