木纳 发表于 2008-5-23 06:25:20

GUICtrlCreateListView的列表刷新问题

下在这个例中,我想点这样操作,点一下“读取列表”,将重新读入ini的 IniReadSectionNames内容,
可是点了一下后,倒是取出来了,但以前的还在,成了重复的了;再点一下,成三个重复的内容了,
能不能,点下后,清空,然后重新读取,请求帮助

#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <Process.au3>
#include <GUIConstants.au3>
#include <guiconstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>



$Form1 = GUICreate("Form1", 604, 546, 508, 164)
$ListView1 = GUICtrlCreateListView(" 列表:", 12, 46, 557, 453, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES, $LVS_EX_CHECKBOXES, $LVS_EX_TRACKSELECT, $LVS_EX_HEADERDRAGDROP, $WS_HSCROLL, $WS_VSCROLL))
$Button1 = GUICtrlCreateButton("读取列表", 160, 8, 265, 33, -1, $WS_EX_CLIENTEDGE)


GUISetState(@SW_SHOW)


Global $inipath = @ScriptDir & "\列表.ini"



While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        _Quit()
                Case $Button1
                        CheckIni()
        EndSwitch
WEnd


Func CheckIni()
        Local $ReadIni
        $ReadIni = IniReadSectionNames($inipath)
        If @error Then
                MsgBox(4096, "", "Error occurred, probably no INI file.")
        Else
                For $i = 1 To $ReadIni
                        $item = GUICtrlCreateListViewItem($ReadIni[$i], $ListView1)
                        $item = GUICtrlSetData($ReadIni[$i], $ListView1)
                Next
        EndIf
        $num = String(GUICtrlRead(GUICtrlRead($ListView1)))
EndFunc   ;==>CheckIni


Func _Quit()
        Exit
EndFunc   ;==>_Quit

[ 本帖最后由 木纳 于 2008-5-23 11:18 编辑 ]

木纳 发表于 2008-5-23 11:18:33

谢谢,感谢二楼兄弟,,,

bbip 发表于 2009-8-29 14:27:45

留个记号 用的着了来查

sanmoking 发表于 2010-1-18 14:29:40

有个专门解决楼主问题的【传送门】
页: [1]
查看完整版本: GUICtrlCreateListView的列表刷新问题