ok... i know a lot of you are probably tired of me asking questions but i am trying to learn and i am asking about stuff i dont know, not just to get you to do the whole program for me. this question is if there is a list of item in a listview, how can i make it so when someone clicks and item then clicks a button that item is removed? then in separate textbox it should add the price even when the item is removed. pls help[

so you want the item remove and when it remove the price add in text box..

well, i need the price to add up to a textbox, it doesnt have to add up when removed. ive tryed having

listview1.selecteditems.item.clear

but it doesnt work, i coulnd not find a remove so i went with clear, i only have vs.net 2003, the only thing i can figure out how to do is clear the whole thing with

listview1.items.item.clear

or something to that effect. but i dont want the whole thing to clear, i want only the one they select to clear

try this following code to remove item on listview :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For Each lvItem As ListViewItem In ListView1.SelectedItems
            lvItem.Remove()
        Next
End Sub

Ok . Hope this helps...

commented: perfect +1

Thats amazing, i would have never thought of that! now how can i get it to add up the names and/or prices to put in the textboxes?

u mean the removed item put in the textbox?

no now i mean like if the listview has 2 columns, one for an items name and one for price. lastnight i was able to get the price column to add up and show in a textbox, now how can i get the name column to "add" up so it be like name1, name2, name3 just in a textbox?

You need to capture that before deleting the items from the list view.

no, what i want is whatever is currently listed in the listview to go in the textbox

I know this is an old thread but I needed something similar to OP, so I thought I would share in case someone else might need this.

This loops thru all the listview items, adds the first item to the textbox, then removes the first item from the listview.

The timer ticks (9000) then repeats the cycle.

If the listview is empty, the timer stops.

Assumes (on form1):

1) listview
2) textbox
3) timer
4) label
5) button

Private Counter2 As Integer = 0

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

        Timer1.Start()

    End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Counter2 = (Counter2 - 1)

        Label9.Text = Counter2

        TextBox1.Text = ""

        TextBox1.Text = ListView3.Items(0).Text

        If ListView3.Items.Count > 0 Then
            ListView3.Items.RemoveAt(0)
        End If

        If ListView3.Items.Count <= 0 Then
            Timer1.Stop()
            Counter2 = 0
        End If

    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.