Jump to content
Sign in to follow this  

Retrive the controlID of an listview item

Recommended Posts

Hi guys,

I'm very newby in autoit (to be honest I'm newby in any development language..) but I WANT to learn

to use autoit.

Well, I'm in trouble trying to retrive the ctrlID of a listview item.

I have a listview populated by an array. My script should shows only items which are related with

some search condition. The selection criteria came from a combo.

To do that I used the following code:


$param0 = GUICtrlRead($comboListviewC)


case $param0 = "code"

$param1 = 0

case $param0 = "firstname"

$param1 = 1

case $param0 = "lastname"

$param1 = 2

case $param0 = "address"

$param1 = 3

case $param0 = "city"

$param1 = 4

case $param0 = "codeC"

$param1 = 5

case $param0 = "phone"

$param1 = 6


$param2 = GUICtrlRead($searchInputC)

$param3 = GUICtrlRead($comboSearchConditionsC)

for $Q = 0 to UBound($arrayC)-1

$string = _GUICtrlListViewGetItemText($listviewC, $Q, $param1)


case $string = $param2

;do nothing

case $string <> $param2

_GUICtrlListViewSetItemSelState($listviewC, $Q, 1)




what happens is that the selected item will be deleted, and this is ok. My problem is that I cannot roll-back to

the previous state: I tried to recreate the entire listview without any result.

I mean that if I use the same code to recreate the listview this works fine, but the select code above does not work..it delete always ALL items!!!

I need the possibility to show all the items again, reduce them whit any search condition and show all of them again..and again ..and again.

I know that the _GUICtrlListViewDeleteItemsSelected() probabily is not the right solution, but I dont find any way to have the controlID of any single item in the listview. Having that ctlrid I should use something like GUICtrlSetState(controlID, @GUI_HIDE)....

plase help me :whistle:

ps1 --sorry for my english;

ps2 --if you need any details you'll be welcome

Share this post

Link to post
Share on other sites


Does this example script do want you want to do ?

#include <GUIConstants.au3>

#include <GuiListView.au3>

Dim $Row[100], $ControlHandle[100]


Dim $Data[100] = ["R1C1|R1C2|R1C3","R2C1|R2C2|R2C3","R3C1|R3C2|R3C3"]

; Create GUI

GUICreate("listview items",220,250, 100,200)

$listview = GuiCtrlCreateListView ("col1 |col2|col3 ",10,10,200,150)

$buttonR2 = GuiCtrlCreateButton ("Display Row 2",10,170,80,20)

$buttonALL = GuiCtrlCreateButton ("Disaply ALL",120,170,80,20)

$ButtondeletR2 = GuiCtrlCreateButton ("Delete Row 2",120,200,80,20)



$msg = GuiGetMsg ()


Case $msg = $buttonR2

_GUICtrlListViewDeleteAllItems ($ListView)

; use either GuiCtrlCreateListViewItem or _GUICtrlListViewInsertItem(


$ControlHandle[1] = GuiCtrlCreateListViewItem($Data[1],$listview)


Case $msg = $buttonALL

_GUICtrlListViewDeleteAllItems ($ListView)

For $Row = 0 to 2

; use either GuiCtrlCreateListViewItem or _GUICtrlListViewInsertItem(


$ControlHandle[$Row] = GuiCtrlCreateListViewItem($Data[$Row],$listview)



Case $msg = $ButtondeletR2

_GUICtrlListViewDeleteItem ($listview,1)


Until $msg = $GUI_EVENT_CLOSE

Edited by rogdog

My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic]

Share this post

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...