Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Listview control - removing one listitem

Listview control - removing one listitem

Listview control - removing one listitem

Does anybody know how one can remove one listitem (that was selected by the clickitem event) from the listview control. I am using the listview control in reportview.

RE: Listview control - removing one listitem

For x% = 1 To ListView1.ListItems.Count
'alle elementen doorlopen
If ListView1.ListItems(x%).Selected = True Then
bestand$ = ListView1.ListItems(x%).Text
'markering aanwezig = wissen
'bestandsnaam samenstellen
Pad$ = Map1.Path
DoelBestand$ = CheckPath$(Pad$) + bestand$
If Antwoord% = vbYes Then
Titel$ = "Let op"
Melding$ = "Moet het bestand " + DoelBestand$ + " worden gewist?"
b% = MsgBox(Melding$, vbYesNo + vbQuestion, Titel$)
'bestand wissen
b% = vbYes
End If
If b% = vbYes Then
Kill DoelBestand$
End If
'labelveld actualiseren
Gewist% = Gewist% + 1
LbBewerkt.Caption = Str$(Gewist%)
End If
Next x%

Eric De Decker
Visual Basic Center

RE: Listview control - removing one listitem

How about something like this:

Private Sub list1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
List1.RemoveItem List1.ListIndex
End If
End Sub

Steve Meier

RE: Listview control - removing one listitem

Click vs. MouseDown... My intent by doing it this way was just clicking on the item in the list wouldn't delete it. You could select it first, and then if you right clicked on it, it would delete it. I thought it might me quite unfriendly if you clicked on the item and then it disappeard on you. This would give the user the ability to select the item to delete and then right click to delete it.

If I were to write this in an actual application, I would pop up a menu based on a right click, where one of the options would be delete.

Good question!

Steve Meier

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close