sliqi 发表于 2011-8-5 20:27:01

ListView图标更换问题【已解决】

本帖最后由 sliqi 于 2011-8-7 00:51 编辑

例;在listview里有5行数据    按下butonn搜索12,然后修改这行的图标,请大侠赐教#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>

Global $from1,$ListView1
$Form1 = GUICreate("我的列表", 360, 320)
$hImage = _GUIImageList_Create(16, 16, 5, 3)
$ListView1 = GUICtrlCreateListView("列a|列b|列c|列d|列e", 8, 8, 361, 150)
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)

$Button_1 = GUICtrlCreateButton("修改12的图标", 10, 180)
$Button_2 = GUICtrlCreateButton("修改14的图标", 10, 230)



for $i = 1 to 5
GUICtrlCreateListViewItem($i&"|1"&$i&"|2"&$i&"|3"&$i&"|4"&$i,$ListView1)
GUICtrlSetImage(-1, "shell32.dll", 18)
Next


GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
   Case $GUI_EVENT_CLOSE
    Exit
       
Case $Button_1
        $con= CONTROLLISTVIEW($from1 , "" , $ListView1, "FindItem" , "12", 1)
       
If $con <> -1 Then
;;这里设置listviewitem图标
;;;


EndIf

EndSwitch
WEnd

www378660084 发表于 2011-8-5 20:55:36


#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>

Global $from1, $ListView1
$Form1 = GUICreate("我的列表", 360, 320)
$hImage = _GUIImageList_Create(16, 16, 5, 3)
$ListView1 = GUICtrlCreateListView("列a|列b|列c|列d|列e", 8, 8, 361, 150)
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)

$Button_1 = GUICtrlCreateButton("修改12的图标", 10, 180)
$Button_2 = GUICtrlCreateButton("修改14的图标", 10, 230)

Dim $list

For $i = 0 To 4
        $list[$i] = GUICtrlCreateListViewItem($i & "|1" & $i & "|2" & $i & "|3" & $i & "|4" & $i, $ListView1)
        GUICtrlSetImage(-1, "shell32.dll", 18)
Next


GUISetState(@SW_SHOW)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

                Case $Button_1
                        $con = ControlListView($from1, "", $ListView1, "FindItem", "12", 1)

                        If $con <> -1 Then
                                ;;这里设置listviewitem图标
                                ;;;
                                GUICtrlSetImage($list[$con], "shell32.dll", 12)

                        EndIf

        EndSwitch
WEnd

页: [1]
查看完整版本: ListView图标更换问题【已解决】