Jump to content

[SOLVED]Listview items being deleted


 Share

Recommended Posts

I did something similar with a program I wrote a few months ago. I used the function I mentioned above along with _GUICtrlListView_GetSelectionMark. Then I used _FileWriteToLine using blank text and parameter #4 with a "1" to delete the line from the file. That code should look something like this:

_FileWriteToLine("computers.txt", $lineNumber, "", 1)
Edited by abberration
Link to comment
Share on other sites

I did something like this below, but the problem is that when the text is added to the text file, and with how I can sort the list ascending vs descending, the GetSelectionMark number doesn't line up with the ListView item.. if that makes sense.

Func delSelected()
GUICtrlListView_DeleteItemsSelected($CompListView)
Local $lineNumber = _GUICtrlListView_GetSelectionMark($CompListView)
ConsoleWrite($lineNumber)
FileWriteToLine("computers.txt", $lineNumber, "", 1)
dataRefresh()
EndFunc
Link to comment
Share on other sites

I think this is the solution you are searching:

Func delSelected()
    Dim $aRecords
    _FileReadToArray("computers.txt", $aRecords)
    Local $index = Int(_GUICtrlListView_GetSelectedIndices($CompListView))
    $SelectedComp = _GUICtrlListView_GetItemTextString($CompListView, $index)
    For $x = 1 To $aRecords[0]
        If $aRecords[$x] = $SelectedComp Then _FileWriteToLine("computers.txt", $x, "", 1)
    Next
    dataRefresh()
EndFunc   ;==>delSelected

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...