lrstndm 1 Posted July 25, 2013 Hi All, I am working on a listview with bitmaps. I want for each row a different bitmap ( a different picture). but my code below will edit all the rows. What am i doing wrong? #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiConstantsEx.au3> #include <WinAPI.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $listview, $hImage GUICreate("ImageList AddBitmap", 400, 300) $listview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($listview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) _GUICtrlListView_AddColumn($listview, "1st", 120) _GUICtrlListView_AddColumn($listview, "2nd", 120) GUISetState() $hImage = _GUIImageList_Create(25, 25) _GUIImageList_AddBitmap($hImage, "picture1.bmp") _GUICtrlListView_SetImageList($listview, $hImage, 1) _GUICtrlListView_AddItem($listview, "Item 1", 0) $hImage = _GUIImageList_Create(25, 25) _GUIImageList_AddBitmap($hImage, "picture2.bmp") _GUICtrlListView_SetImageList($listview, $hImage, 1) _GUICtrlListView_AddItem($listview, "Item 2", 0) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc Greets, lrstndm Share this post Link to post Share on other sites
Artisan 4 Posted July 25, 2013 (edited) I found 2 little problems. 1) It seems that you have to create your image list first before you add rows to the listview. 2) You referenced index 0 both times you called _GUICtrlListView_AddItem (understandable given your approach, but AutoIt doesn't seem to like that) Here's what I got to work: #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiConstantsEx.au3> #include <WinAPI.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $listview, $hImage GUICreate("ImageList AddBitmap", 400, 300) $listview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($listview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) _GUICtrlListView_AddColumn($listview, "1st", 120) _GUICtrlListView_AddColumn($listview, "2nd", 120) GUISetState() $hImage = _GUIImageList_Create(25, 25) _GUIImageList_AddBitmap($hImage, "picture1.bmp") _GUIImageList_AddBitmap($hImage, "picture2.bmp") _GUICtrlListView_SetImageList($listview, $hImage, 1) _GUICtrlListView_AddItem($listview, "Item 1", 0) _GUICtrlListView_AddItem($listview, "Item 2", 1) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc Edited July 25, 2013 by Artisan Share this post Link to post Share on other sites
lrstndm 1 Posted July 26, 2013 Thanks it is working:) Share this post Link to post Share on other sites