Results 1 to 6 of 6

Thread: Keeping track of the last selected list

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2001
    Location
    BX, NY
    Posts
    42

    Question Keeping track of the last selected list

    I have Form1 that has a listbox, i need to go to Form2 from Form1 and then return to Form 1, how can I keep track of the currently selected list row?

  2. #2

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2001
    Location
    BX, NY
    Posts
    42
    Yes i am refreshing the listbox when i return to Form1.

  4. #4

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2001
    Location
    BX, NY
    Posts
    42
    CORRECTION: I'm using a listview.

    Trying to stay away from globals.

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    Originally posted by mmr93
    Trying to stay away from globals.
    That's always a good idea.

    Add the following to Form1.

    VB Code:
    1. Option Explicit
    2. Private mintIndex As Integer
    3.  
    4. Public Property Get ItemSelected() As Integer
    5.  
    6.     ItemSelected = mintIndex
    7.  
    8. End Property
    9.  
    10. Public Property Let ItemSelected(ByVal intNdx As Integer)
    11.  
    12.     mintIndex = intNdx
    13.  
    14. End Property

    Usage:

    ' To save the value
    ItemSelected = MyListView.SelectedItem.Index

    ' To reset it
    Dim itmX As ListItem

    Set itmX = MyListView.ListItems(ItemSelected)
    itmX.Selected = True

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