Problem with Listview
-
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=nbut this seems to be wrong code can u please suggest some another... i am beginner Please help... :) :)
-
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=nbut this seems to be wrong code can u please suggest some another... i am beginner Please help... :) :)
- 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)
Nextme.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
-
- 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)
Nextme.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
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)
Nextme.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. :) :) :)