Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove a row (item) from a VB6 ListView using a button?

Tags:

listview

vb6

How do I delete a row in a ListView. I need to select the row to be deleted and a command button will delete it with a alert message if you want to delete the row. What will be the code for that?

like image 532
gibz357 Avatar asked Jan 30 '26 03:01

gibz357


1 Answers

Assuming you already created ListView (ListView1) and a Click event for the button (let's call it button1), by double-clicking on it, the could would go something like this:

So the code would go something like this:

private sub Button1_Click()
    if ListView1.SelectedItem is nothing then exit sub

    if MsgBox("Do you really want to delete?", "Question", vbYesNo) = vbYes then
        ListView1.ListItems.Remove ListView1.SelectedItem.Index
    end if
end sub
like image 154
AngryHacker Avatar answered Jan 31 '26 19:01

AngryHacker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!