Use of Listview
-
Hello Every one, I am want addition of listview text and display it in label For eg: There is one listview and there are 3 records in it (100,200,300)respectively. now what i want is total of all these records and display it in lable1.text total =100+200+300(This numeric values comes from database) label1.text=total and this should happen each time at listview mouse double click event I stated below code in listview mouse double click event
Dim Tot As Integer = 0
For i As Integer = 0 To Me.lstview2.Items.Count - 1 Tot += CInt(Me.lstview2.SelectedItems(i).SubItems(i).Text) Tot += CInt(Me.lstview2.SelectedItems(i).SubItems(i).Text) Next Me.Label1.Text = Tot
but this only gives me position of the selected text So how shall i approach please suggest... Thank You :) :) :)
-
Hello Every one, I am want addition of listview text and display it in label For eg: There is one listview and there are 3 records in it (100,200,300)respectively. now what i want is total of all these records and display it in lable1.text total =100+200+300(This numeric values comes from database) label1.text=total and this should happen each time at listview mouse double click event I stated below code in listview mouse double click event
Dim Tot As Integer = 0
For i As Integer = 0 To Me.lstview2.Items.Count - 1 Tot += CInt(Me.lstview2.SelectedItems(i).SubItems(i).Text) Tot += CInt(Me.lstview2.SelectedItems(i).SubItems(i).Text) Next Me.Label1.Text = Tot
but this only gives me position of the selected text So how shall i approach please suggest... Thank You :) :) :)
Change your code to something like this:
Dim Tot As Integer = 0 For i As Integer = 0 To Me.lstview2.Items.Count - 1 Tot += CInt(Me.lstview2.Items(i).SubItems(1).Text) Next Me.Label1.Text = Tot
you may have to change then 1 in 'SubItems(1)' to the column where your numbers are stored.Tosch