Sign in to follow this  
Followers 0
Cravin

[SOLVED]Listview items being deleted

7 posts in this topic

#1 ·  Posted (edited)

Thanks Autobert, issue resolved.

Edited by Cravin

Share this post


Link to post
Share on other sites



You're right, but I also need it to remove the line from the computers.txt file as well... that's the issue

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

AutoBert,

You fricken nailed it. Thanks a million man.

Share this post


Link to post
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
Sign in to follow this  
Followers 0