I have Listview1 and listview2
After from listview1 focus to listview2
ex: row 20

keydown listview2 not go to row 21
but go to row 1, also keyUp not go to row 19 but go to row 1

any one can help, what to do

Thanks

try this code

'use this code on the keydown event of the listbox
If e.KeyData = Keys.Down Then
            ListBox1.SelectedItem = ListBox1.Items(0)
        End If
        If e.KeyData = Keys.Up Then
            ListBox1.SelectedItem = ListBox1.Items(0)
        End If

Hope this helps you

Regards

ListBox1.SelectedItem = ListBox1.Items(0)

Property SelectedItems is ReadOnly

Check this Out , May be this will help you :)

calculator is listbox
not listview

Not quite clear on your question.
Are you using the KeyUp/KeyDown Events for the ListView or are you referring to the Up/Down arrow keys on your keyboard?

Private Sub ListGroup_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ListGroup.KeyPress
If Not ListGroup.SelectedItems.Count = 0 Then
With ListGroup.SelectedItems(0)
Dim foundItem As ListViewItem = ListProduct.FindItemWithText(.Text, True, 0, True)

If foundItem IsNot Nothing Then
ListProduct.MultiSelect = False
ListProduct.TopItem = foundItem
foundItem.Selected = True
ListProduct.Select()
ListProduct.Focus()

End If
End With
End If
End Sub

keydown can work after listproduct have one click mouse

Now which ListView isNot responding properly? ListGroup or ListProduct?

"keydown" on which ListView?

See if this helps.

Private Sub _ListProduct_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListProduct.KeyDown
        With CType(sender, ListView)
            If Not .Items.Count = 0 Then
                .MultiSelect = False
                e.Handled = True '// block default handling.
                Select Case e.KeyCode
                    Case Keys.Up
                        .Items(0).Selected = True '// select first item.
                    Case Keys.Down
                        .Items(.Items.Count - 1).Selected = True '// select last item.
                End Select
                .SelectedItems(0).EnsureVisible() '// make sure that item is visible once selected.
                .HideSelection = False '// keep cute highlight on item.
            End If
        End With
    End Sub

Now keydown from keyboard can down but to last row not to row 21
keyup and keydown only go to first row and lastrow....

keydown listview2 not go to row 21
but go to row 1, also keyUp not go to row 19 but go to row 1

any one can help, what to do

Is there still an issue?

Private Sub ListProduct_ItemSelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.ListViewItemSelectionChangedEventArgs) Handles ListProduct.ItemSelectionChanged
ListProduct.FullRowSelect = True
ListProduct.HideSelection = False
If Not ListProduct.SelectedItems.Count = 0 Then
Dim lvi As ListViewItem
For Each lvi In ListProduct.SelectedItems
lvi.Focused = True '/// highlight any selected items.
Next
End If
End Sub

Solved... thanks codeorder

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.