Jump to content

Save and Load contents of a listview


bobbo85
 Share

Recommended Posts

I have a listview with 9 columns, is there a way to save that data to a text file and import the data back into the listview later?

I see that there is a function _GUICtrlListView_GetItemTextArray that will read all fields to an array, and _GUICtrlListView_AddArray that will read an array into a listview, but are the two formats the same? So far, all I have in the code is the code to create a file or open a file, but I have not written or read from the file.

func savequeue()
    $savelocation=FileSaveDialog ("Save Queue", @DesktopCommonDir&"\", "Text (*.txt)",16,"my queue.txt")
    FileOpen ($savelocation, 2);creates file
endfunc

Func openqueue()
    $queuelocation=FileOpenDialog("Open Queue",@DesktopCommonDir&"\", "Text (*.txt)",16,"")
    FileOpen ($queuelocation, 0);opens the saved file
endfunc
Link to comment
Share on other sites

Hi,

I hope it's not too late...

If you want to use the "_GUICtrlListView_AddArray" you may should use an ini file with sections instead of text file.

This would be much more easy as you can use "IniReadSections" function to get all items for a section, and the result is already stored in a 2 dimentional array.

Use "IniWriteSection" to update the ini file using Listview items values.

Hope this will help.

FreeRiderHonour & Fidelity

Link to comment
Share on other sites

Here's something from a program I made a while ago that reads stuff from an ini file into a listview

$listview = _GUICtrlListView_Create($GuiHwnd, "", 60, 55, 330, 200)
_GUICtrlListView_SetExtendedListViewStyle($listview, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_InsertColumn($listview, 0, "Name ", 110)
_GUICtrlListView_InsertColumn($listview, 1, "IP", 160)
$names = IniReadSectionNames("file.ini")
For $names1 = 1 To $names[0]
    $ip = IniRead("file.ini", $names[$names1], "ip", "No DNS")
    $number = _GUICtrlListView_GetItemCount($listview)
    ;Make list items
    _GUICtrlListView_AddItem($listview, $names[$names1], 0)
    _GUICtrlListView_AddSubItem($listview, $number, $ip, 1)
    ;End list items
Next

Hope this helps. ;)

Edited by killerofsix

"The quieter you are, the more you are able to hear..."

My AppsUSB Finder

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...