Results 1 to 2 of 2

Thread: Listbox

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    52

    Listbox

    I have two buttons one "prev" and one "next" I want to go through the records of a listbox. When I reach the end I want it to go to the first record.

    I appriciate your help

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Listbox

    VB Code:
    1. Private Sub cmdNext_Click()
    2. 'Select Next selection
    3. If ListView1.SelectedItem.Index < ListView1.ListItems.Count Then
    4.     ListView1.ListItems(ListView1.SelectedItem.Index + 1).Selected = True
    5. Else
    6.     ListView1.ListItems(1).Selected = True
    7. End If
    8.     'Set focus
    9.     ListView1.SelectedItem.EnsureVisible
    10.     ListView1.SetFocus
    11. End Sub
    12.  
    13. Private Sub cmdPrev_Click()
    14. 'Select Prev selection
    15. If ListView1.SelectedItem.Index > 1 Then
    16.     ListView1.ListItems(ListView1.SelectedItem.Index - 1).Selected = True
    17. Else
    18.     ListView1.ListItems(ListView1.ListItems.Count).Selected = True
    19. End If
    20.     'Set focus
    21.     ListView1.SelectedItem.EnsureVisible
    22.     ListView1.SetFocus
    23. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width