Dear Sir/Madam,
I have used Pop Up menu to show the list_Item of a list box on Up and Down Arrow KeyPressed event. But here i can't see the list item continuously by pressing up or down keys, either i have to click/enter on that pop up menu or in the form to see the next list_item. How can we see the list item continuously by pressing up or down arrow keys. Please guide me.
If KeyCode = vbKeyDown Then
If List1.ListIndex = List1.ListCount - 1 Then
List1.Selected(List1.ListIndex) = True
LstName.Caption = List1.Text
PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
ElseIf List1.ListIndex = -1 Then
List1.Selected(List1.ListIndex + 1) = True
LstName.Caption = List1.Text
PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
List1.Selected(List1.ListIndex) = False
Else
List1.Selected(List1.ListIndex + 1) = True
LstName.Caption = List1.Text
PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
List1.Selected(List1.ListIndex - 1) = True
End If
ElseIf KeyCode = vbKeyUp Then
If List1.ListIndex = List1.TopIndex Then
List1.Selected(List1.ListIndex) = True
LstName.Caption = List1.Text
PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
ElseIf List1.ListIndex = -1 Then
List1.Selected(List1.ListIndex + 1) = True
LstName.Caption = List1.Text
PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
'List1.Selected(List1.ListIndex) = False
Else
List1.Selected(List1.ListIndex - 1) = True
LstName.Caption = List1.Text
PopupMenu MnuPopup, , List1.Left + List1.Width / 2, List1.Top + List1.Height / 2
List1.Selected(List1.ListIndex + 1) = True
End If
End If