Hi all,
I got the key arrow down to work right but the key up still doesn't? I
tappears to
focus on the correct one but then I cannot move up anymore with the up
arrow.
The focus is not working correctly.
Private Sub ListView2_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles ListView2.KeyDown
If ListView2.SelectedItems(0).Index = (ListView2.Items.Count - 1)
And e.KeyCode = Keys.Down Then
ListView2.Items(0).Focused = True
ListView2.Items(0).Selected = True
ListView2.Items(0).EnsureVisible()
e.Handled = True
End If
If ListView2.SelectedItems(0).Index = 0 And e.KeyCode = Keys.Up Then
ListView2.Items(ListView2.Items.Count - 1).Focused = True
ListView2.Items(ListView2.Items.Count - 1).Selected = True
ListView2.Items(ListView2.Items.Count - 1).EnsureVisible()
e.Handled = True
End If
End Sub
[quoted text, click to view] "gv" <viatorg@musc.edu> wrote in message
news:%23EncOA3%23FHA.1248@TK2MSFTNGP14.phx.gbl...
> Hi
>
> This will not work nor do I get an error?
>
> Will not set the first item when the selected item gets to the last one by
> pressing the down arrow
> key.
>
> Private Sub ListView2_KeyDown(ByVal sender As Object, ByVal e As
> System.Windows.Forms.KeyEventArgs) Handles ListView2.KeyDown
>
> If ListView2.SelectedItems(0).Index = (ListView2.Items.Count - 1)
> And e.KeyCode = Keys.Down Then
> ListView2.Items(0).Selected = True
> ListView2.Select()
> e.Handled = True
>
> ElseIf ListView2.SelectedItems(0).Index = 0 And e.KeyCode = Keys.Up
> Then
> ListView2.Items(ListView2.Items.Count - 1).Selected = True
> ListView2.Select()
> e.Handled = True
>
> End If
>
> End Sub
>
> thanks
> Gerry
>