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. General Programming
  3. Visual Basic
  4. Problem with Listview

Problem with Listview

Scheduled Pinned Locked Moved Visual Basic
helpdatabaselearning
3 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.
  • N Offline
    N Offline
    nazimghori
    wrote on last edited by
    #1

    Hello Every One I am having one listview in that i am adding one column like

    me.listview1.column.add("Rupees,50,Horizontal.centre")

    now i fetch records from database in it for filling listview and it worked but the problem is i want to add the Rupees of listview and display it in one label For that my code is like:

    dim i as string
    dim n as integer
    dim t as integer =me.listview1.count
    for i = to t-1
    n=i+me.listview1.selecteditem(0).subitem(1).text
    me.label1.text=n

    but this seems to be wrong code can u please suggest some another... i am beginner Please help... :) :)

    N 1 Reply Last reply
    0
    • N nazimghori

      Hello Every One I am having one listview in that i am adding one column like

      me.listview1.column.add("Rupees,50,Horizontal.centre")

      now i fetch records from database in it for filling listview and it worked but the problem is i want to add the Rupees of listview and display it in one label For that my code is like:

      dim i as string
      dim n as integer
      dim t as integer =me.listview1.count
      for i = to t-1
      n=i+me.listview1.selecteditem(0).subitem(1).text
      me.label1.text=n

      but this seems to be wrong code can u please suggest some another... i am beginner Please help... :) :)

      N Offline
      N Offline
      nlarson11
      wrote on last edited by
      #2
      1. you have ' dim i as string ' but are using 'i' in the for next loop. change to 'as integer' 2) is your intention to add up all the selected items? if so, you aren't doing that. you are adding the same value of the first selected item for as many rows that there are total. 3) The for next loop is declared as 'to listview1.count - 1' inorder to add up all the selecteditems, you need to change that to 'to listview1.selecteditems.count - 1'. 4) where's the word 'next' at the end of the loop

      Dim Tot as integer = 0

      For i as integer = 0 to listview1.selecteditems.count -1
      Tot += cint(me.listview1.selecteditems(i).subitem(1).text)
      Next

      me.label1.text = Tot

      Hope this helps... Nathan

      'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous

      N 1 Reply Last reply
      0
      • N nlarson11
        1. you have ' dim i as string ' but are using 'i' in the for next loop. change to 'as integer' 2) is your intention to add up all the selected items? if so, you aren't doing that. you are adding the same value of the first selected item for as many rows that there are total. 3) The for next loop is declared as 'to listview1.count - 1' inorder to add up all the selecteditems, you need to change that to 'to listview1.selecteditems.count - 1'. 4) where's the word 'next' at the end of the loop

        Dim Tot as integer = 0

        For i as integer = 0 to listview1.selecteditems.count -1
        Tot += cint(me.listview1.selecteditems(i).subitem(1).text)
        Next

        me.label1.text = Tot

        Hope this helps... Nathan

        'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous

        N Offline
        N Offline
        nazimghori
        wrote on last edited by
        #3

        hello

        Dim Tot as integer = 0

        For i as integer = 0 to listview1.selecteditems.count -1
        Tot += cint(me.listview1.selecteditems(i).subitem(1).text)
        Next

        me.label1.text = Tot

        The code u suggested just gives me the one by one value of items present in listview eg :i placed this code on listview double click event so it just give me value 1 when i double click on selected row and then 2 and goes on. but i want the total of the items present in row and display it in label for eg:suppose there are two listviews both are having columns as Rupees but the first one is having Rs in it like(100,200,300 etc..) what i want is when i double click on any of row of first listview it adds the items preset in the selected row one by one and displays it in label like (100+200+300) which gives result as 600 in label simply saying i want total of text present in the listview so please suggest if some have any idea. Thank You. :) :) :)

        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