i have a list box and a button. i would like when the button is clicked the selected item in the list box is deleted. any ideas?
ng5
9
Light Poster
Recommended Answers
Jump to Postyes you can do it in this way
Try ListBox1.Items.Remove(ListBox1.SelectedItem) Catch ex As Exception MsgBox(Err.Description) End Try
Hope this will Solve your prob .
Regards
Jump to PostTry this....
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If Me.ListBox1.SelectedIndex > -1 Then Me.ListBox1.Items.RemoveAt(Me.ListBox1.SelectedIndex) End If End Sub
All 5 Replies
renzlo
4
Junior Poster in Training
M.Waqas Aslam
67
Posting Pro in Training
Featured Poster
kingsonprisonic
42
Posting Whiz in Training
Jx_Man
987
Nearly a Senior Poster
Featured Poster
kingsonprisonic
commented:
No Need of loop....
-1
ng5
9
Light Poster
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.