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

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

+3
source share
2 answers

Assuming you have already created a ListView (ListView1) and a Click event for a button (call button 1), double-clicking on it may result in something like this:

So, the code will look 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
+6
source

What controls have you used and what code have you written to make this happen? (You can add this information to your question by editing it).

, , ListView (, ListView1) Button (, DeleteRow), , DeleteRow_Click ( , , , ).

DeleteRow_Click. :

  • () ListView ListView1.SelectedItem. SelectedItem - : VB Object Explorer / Intellisense . , , , ListView NO item: , , SelectedItem , ( , , ...)

  • ListView1 , : ListItems ( .Remove...), F2 Intellisense

  • , , MessageBox: , Windows API, , ( ), , ( ). , , .

0

Source: https://habr.com/ru/post/1724210/


All Articles