Results 1 to 5 of 5

Thread: [VC++] Last Selected Item in ListBox

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    [VC++] Last Selected Item in ListBox

    Hello, how do I get the last selected item in a ListBox?

    The user is able to select multiple items in the listbox, but I want to know which item the user selected last. I am using ListBox.SelectedItems to get the array of items selected, I thought I could just check the last item in the array, but it doesn't work like that. The last item in the array is not the last item selected. It doesn't add on values to the array, it simply checks off which item has been selected..

    I was looking on MSDN and I couldn't find anything.. Does anyone know of a way to do this?

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [VC++] Last Selected Item in ListBox

    I tried this using VB6. Seems to be working:
    Code:
    '// VB6 Code
    Private Sub List1_Click()   '// on clicking
    
        MsgBox List1.ListIndex  '// display the Index in a messagebox
        
    End Sub
    ...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    Re: [VC++] Last Selected Item in ListBox

    On a ListBox? There is no property called ListIndex...

    I checked this: http://msdn.microsoft.com/en-us/libr...25(VS.60).aspx

    Couldn't find anything...

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    Re: [VC++] Last Selected Item in ListBox

    Is there no built in function to do this?

    If there isn't I guess I can always compare the currently selected items with the selected items before..

  5. #5
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [VC++] Last Selected Item in ListBox

    Quote Originally Posted by noahssite View Post
    On a ListBox? There is no property called ListIndex...

    I checked this: http://msdn.microsoft.com/en-us/libr...25(VS.60).aspx

    Couldn't find anything...
    I'm not sure about VC++. I'm using VB6

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

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