We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

VB and Forms

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
2
Contributors
4
Replies
3 Hours
Discussion Span
5 Months Ago
Last Updated
5
Views
t2nator
Newbie Poster
22 posts since Dec 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

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

tinstaafl
Nearly a Posting Virtuoso
1,470 posts since Jun 2010
Reputation Points: 429
Solved Threads: 262
Skill Endorsements: 14

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

t2nator
Newbie Poster
22 posts since Dec 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

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
t2nator
Newbie Poster
22 posts since Dec 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

You could try something like this:

        For Each lvi As ListViewItem In ListView1.SelectedItems
            ListView1.Items.Remove(lvi)
        Next
tinstaafl
Nearly a Posting Virtuoso
1,470 posts since Jun 2010
Reputation Points: 429
Solved Threads: 262
Skill Endorsements: 14

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0658 seconds using 2.67MB