I'm using the Visual Basic that comes with Visual Studio 2012 Utlimate, and everything I find online doesnt ever work. I am simply trying to make it to when a button is clicked the rows that are checked get deleted.

Do While TodaysTrans.SelectedItems.Count > 0
            TodaysTrans.Items.Remove(TodaysTrans->CheckBox.Equals(true))
Loop

Recommended Answers

All 4 Replies

is your problem with the code to delete rows, or tying the code to the button click?

Mainly the code to delete rows, I have a form that has a ListView for the data to populate along with checkboxes.

Here's an an Example I was lookin at:
http://www.codeproject.com/Tips/170900/How-to-Delete-Selected-Items-of-ListView-and-ListB

And what I have below wont let me use the ListView functions without adding a random 0 after each call?

    Private Sub RemoveTr_Click(sender As Object, e As EventArgs) Handles RemoveTr.Click
        Dim temp As String
        Do While (TodaysTrans.SelectedItems.Count > 0)
            TodaysTrans.Items.Remove(TodaysTrans.SelectedItems(0))
        Loop
        temp = TodaysTrans.SelectedItems.Item(0).ToString(0)
        MsgBox(temp)
        Control.MySQLConductor("ryan", "Doyle2233", "localhost", SetL, "DELETE From list WHERE Name= @one", temp)
        TodaysTrans.Clear()
        Control.MySQLListAdd("ryan", "Doyle2233", "localhost", SetL, "list", "Name", TodaysTrans)
    End Sub
End Class

You could try something like this:

        For Each lvi As ListViewItem In ListView1.SelectedItems
            ListView1.Items.Remove(lvi)
        Next
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.