Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Mutiple Selected Listbox

Mutiple Selected Listbox

Scheduled Pinned Locked Moved Visual Basic
questionlounge
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cylix2000
    wrote on last edited by
    #1

    I have a listbox which can multiple select. How can I get the newest selectItem ? I means I have already select 2 item, how can I get the last item i selected? Suppose the user may random select.

    M 1 Reply Last reply
    0
    • C cylix2000

      I have a listbox which can multiple select. How can I get the newest selectItem ? I means I have already select 2 item, how can I get the last item i selected? Suppose the user may random select.

      M Offline
      M Offline
      Muhammad Javed Khan
      wrote on last edited by
      #2

      'Declare a form level variable as Inherits System.Windows.Forms.Form Private lstLastItem As Integer 'Move the index of selected item of list box into the lstLastItem Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged lstLastItem = ListBox1.SelectedIndex End Sub

      C 1 Reply Last reply
      0
      • M Muhammad Javed Khan

        'Declare a form level variable as Inherits System.Windows.Forms.Form Private lstLastItem As Integer 'Move the index of selected item of list box into the lstLastItem Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged lstLastItem = ListBox1.SelectedIndex End Sub

        C Offline
        C Offline
        cylix2000
        wrote on last edited by
        #3

        lstLastItem = ListBox1.SelectedIndex SelectedIndex seems always return the smallest one. Not that Laterest one. That is when I select index 0 item and then select index 1 item, It also return index 0 but not the laterest index 1... anyway, Thank you

        M 1 Reply Last reply
        0
        • C cylix2000

          lstLastItem = ListBox1.SelectedIndex SelectedIndex seems always return the smallest one. Not that Laterest one. That is when I select index 0 item and then select index 1 item, It also return index 0 but not the laterest index 1... anyway, Thank you

          M Offline
          M Offline
          Muhammad Javed Khan
          wrote on last edited by
          #4

          'Declare a form level variable as Inherits System.Windows.Forms.Form Private lstLastItem As Integer 'Move the index of selected item of list box into the lstLastItem Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged lstLastItem = ListBox1.SelectedIndex End Sub lstLastItem will contain the last index if u want to access the last selected item u may access it as MsgBox(ListBox1.Items.Item(lstLastItem))

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups