Modify ↓
#1639 closed Bug (No Bug)
Unable to delete ListviewItems created with _GUICtrlListView_AddItem
| Reported by: | Emiel Wieldraaijer | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | 3.3.6.1 | Severity: | None |
| Keywords: | Delete Listview _GUICtrlListView_AddItem _GUICtrlListView_DeleteAllItems | Cc: |
Description
Hi,
The code below with "_GUICtrlListView_AddItem" does not allow a listview item to be removed from the listview. If i use GUICtrlCreateListViewItem the item can be removed.
Thanks
Best regards,
Emiel
#Region
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Add_Constants=n
#EndRegion
#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>
#Include <GuiImageList.au3>
Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES,$LVS_EX_CHECKBOXES)
$GUI = GUICreate ("Test", 400,300)
$Tab = GUICtrlCreateTab(10,10, 380,280)
$Tab1 = GUICtrlCreateTabItem("Tab1")
$List = GUICtrlCreateListView ("", 20,40,360,200, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($list, $exStyles)
_AddDrives ()
$Button1 = GUICtrlCreateButton("Delete", 280, 260, 100, 20)
$Button2 = GUICtrlCreateButton("Add", 180, 260, 100, 20)
$Tab2 = GUICtrlCreateTabItem("Tab2")
GuiCtrlCreateLabel("Tab 2", 20,40,100,20)
GUISetState ()
$hImage = _GUIImageList_Create(16, 16, 5, 3)
For $i = 1 to 26
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110 + $i)
Next
_GUICtrlListView_SetImageList($list, $hImage, 1)
_GUICtrlListView_AddColumn($list, "Drive", 85)
_GUICtrlListView_AddColumn($list, "Column 2", 85)
_GUICtrlListView_AddColumn($list, "Column 3", 85)
_GUICtrlListView_AddColumn($list, "Column 4", 85)
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then Exit
Switch $msg
Case -3
ExitLoop
Case -50 To 0
ContinueLoop
Case $msg = 0
Case $Button1
_GUICtrlListView_DeleteAllItems($list)
Case $Button2
_AddDrives()
EndSwitch
Wend
Func _AddDrives ()
$DriveSet = ""
$DriveSet = DriveGetDrive("ALL")
For $i = 1 to $DriveSet[0]
; Unable to delete lines created with this
_GUICtrlListView_AddItem($list, StringUpper($driveset[$i]), 0 + $i)
; But able to delete lines created with this, disable the above line
; GUICtrlCreateListViewItem(StringUpper($DriveSet[$i]), $list)
Next
EndFunc
Attachments (0)
Change History (2)
comment:1 follow-up: ↓ 2 Changed 15 years ago by Jpm
- Resolution set to No Bug
- Status changed from new to closed
comment:2 in reply to: ↑ 1 Changed 15 years ago by anonymous
Replying to Jpm:
If you use _GUICtrl...() functions you better to use _GUICtrl..._Create().
Some mixing works but not all. in your case just change to
;~ $List = GUICtrlCreateListView ("", 20,40,360,200, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) $List = _GUICtrlListView_Create ($GUI, "", 20,40,360,200, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
JPM it's a bug -> In other _GUICtrlListView_ there is mentioned that it will only work with _GUICtrlListView_Create .. there is no reference to it that it will not work ..
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
Note: See
TracTickets for help on using
tickets.

If you use _GUICtrl...() functions you better to use _GUICtrl..._Create().
Some mixing works but not all. in your case just change to
;~ $List = GUICtrlCreateListView ("", 20,40,360,200, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) $List = _GUICtrlListView_Create ($GUI, "", 20,40,360,200, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))