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
  1. Home
  2. Web Development
  3. ASP.NET
  4. Listbox multiple selection

Listbox multiple selection

Scheduled Pinned Locked Moved ASP.NET
question
2 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.
  • V Offline
    V Offline
    vidhu raj
    wrote on last edited by
    #1

    Hi everybody I have two listboxes. I have set the selectmode to multiple but when i select multiple items from listbox1, and then clcik ADD button, only one item is getting added How can i add all the selected items at a time I am using Protected Sub btnAdd_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.ServerClick Dim licCollection As ListItemCollection licCollection = New ListItemCollection() Dim intCount As Integer For intCount = 0 To lstAllAccounts.Items.Count - 1 Step intCount + 1 If (lstAllAccounts.Items(intCount).Selected = True) Then licCollection.Add(lstAllAccounts.Items(intCount)) End If Next Dim intCount1 As Integer For intCount1 = 0 To licCollection.Count - 1 Step intCount + 1 lstAllAccounts.Items.Remove(licCollection(intCount1)) lstAccountAccess.Items.Add(licCollection(intCount1)) Next End Sub thanks

    D 1 Reply Last reply
    0
    • V vidhu raj

      Hi everybody I have two listboxes. I have set the selectmode to multiple but when i select multiple items from listbox1, and then clcik ADD button, only one item is getting added How can i add all the selected items at a time I am using Protected Sub btnAdd_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.ServerClick Dim licCollection As ListItemCollection licCollection = New ListItemCollection() Dim intCount As Integer For intCount = 0 To lstAllAccounts.Items.Count - 1 Step intCount + 1 If (lstAllAccounts.Items(intCount).Selected = True) Then licCollection.Add(lstAllAccounts.Items(intCount)) End If Next Dim intCount1 As Integer For intCount1 = 0 To licCollection.Count - 1 Step intCount + 1 lstAllAccounts.Items.Remove(licCollection(intCount1)) lstAccountAccess.Items.Add(licCollection(intCount1)) Next End Sub thanks

      D Offline
      D Offline
      dinus28
      wrote on last edited by
      #2

      remove the part 'Step intCount + 1 in the second loop. it will work

      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