Jump to content

help ListView & XML (load and search)


icemax
 Share

Recommended Posts

(help ListView & XML (load and search) )

(how to dynamically insert and search items from XML file to ListView )

Hello to all,

I wanted help for insert items from XML file to ListView control

example structure of listview :

Group|Item

Questions: :)

1 - I would like search items and group from 2 textbox ((item and group) and dynamically load to list

2 - I want load the results found from txtbox (item and group) to listview

example of use :

a - insert text to "item" txtbox and code..search and load to listview -> the items and relative group

b- insert text to "GROUP" txtbox and code..search and load to listview -> the group and relative all items

example XML file :

<?xml version="1.0" encoding="ISO-8859-1"?>
<menu title="XMLMenu">
    <menu Group="Games">
        <item caption="Sol Windows XP" cmd="sol.exe"/>
        <item caption="WinMine - XP Game" cmd="winmine.exe"/>
    </menu>
    <menu Group="Programs">
        <item caption="Wordpad2" cmd="wordpad.exe"/>
    </menu>
    <menu Group="Others">
        <item caption="reboot XP" cmd="reboot.exe"/>
        <item caption="RemoveWGA" cmd="\XP - WGA CRACK e Guida\RemoveWGA.exe"/>
    </menu>

Thanks very much for answers :)

Edited by icemax
Link to comment
Share on other sites

This?

#include <GuiConstantsEx.au3>

$sFile = @ScriptDir & "\test.xml"
$sRead = FileRead($sFile)

$aGroup = StringRegExp($sRead, '(?i)Group="(.*?)"', 3)
If @error Then Exit

$aItem = StringRegExp($sRead, '(?i)caption="(.*?)"', 3)
If @error Then Exit

$iUbound = UBound($aGroup)
If UBound($aItem) > $iUbound Then $iUbound = UBound($aItem)

GUICreate("XML to ListView demo", 300, 200)

$ctlListView = GUICtrlCreateListView("Group|Item", 10, 10, 280, 180)

For $i = 0 To $iUbound - 1
    $strData = ""
    If UBound($aGroup) > $i Then $strData &= $aGroup[$i]
    If UBound($aItem) > $i Then $strData &= "|" & $aItem[$i]
    GUICtrlCreateListViewItem($strData, $ctlListView)
Next

GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
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...