Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listview control - removing one listitem

Status
Not open for further replies.

peekay

Programmer
Oct 11, 1999
324
ZA
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.
 
For x% = 1 To ListView1.ListItems.Count<br>
'alle elementen doorlopen<br>
If ListView1.ListItems(x%).Selected = True Then<br>
bestand$ = ListView1.ListItems(x%).Text<br>
'markering aanwezig = wissen<br>
'bestandsnaam samenstellen<br>
Pad$ = Map1.Path<br>
DoelBestand$ = CheckPath$(Pad$) + bestand$<br>
If Antwoord% = vbYes Then<br>
Titel$ = &quot;Let op&quot;<br>
Melding$ = &quot;Moet het bestand &quot; + DoelBestand$ + &quot; worden gewist?&quot;<br>
b% = MsgBox(Melding$, vbYesNo + vbQuestion, Titel$)<br>
Else<br>
'bestand wissen<br>
b% = vbYes<br>
End If<br>
If b% = vbYes Then<br>
Kill DoelBestand$<br>
ListView1.Refresh<br>
End If<br>
'labelveld actualiseren<br>
Gewist% = Gewist% + 1<br>
LbBewerkt.Caption = Str$(Gewist%)<br>
LbBewerkt.Refresh<br>
End If<br>
Next x% <p>Eric De Decker<br><a href=mailto:vbg.be@vbgroup.nl>vbg.be@vbgroup.nl</a><br><a href= Visual Basic Center</a><br>
 
How about something like this:<br>
<br>
Private Sub list1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)<br>
If Button = vbRightButton Then<br>
List1.RemoveItem List1.ListIndex<br>
End If<br>
End Sub<br>
<p>Steve Meier<br><a href=mailto:sdmeier@jcn1.com>sdmeier@jcn1.com</a><br><a href= > </a><br>
 
MouseDown - not Click?<br>
<br>
Mike<br>
<p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
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.<br>
<br>
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.<br>
<br>
Good question! <p>Steve Meier<br><a href=mailto:sdmeier@jcn1.com>sdmeier@jcn1.com</a><br><a href= > </a><br>
 
And good response - it might very well be a bit unfriendly to delete stuff as people click on it.<br>
<br>
I don't write my applications like that - honest!<br>
<br>
-ml<br>
<p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top