Jump to content

how to detect item change in listview?


cntour
 Share

Recommended Posts

$myList = GUICtrlCreateListView("Name|Description|Status|Startup Type|Log On As", 10, 15, 550, 300)

$GUICtrlCreateListViewItem($ServiceName & "|" & $ServiceDes &"|"&$ServiceStatus&"|" &$ServiceStartType&"|"&$ServiceLogOnAs, $h_LV)

While 1

$msg = GUIGetMsg()

If $msg = 0 Then ContinueLoop

If $msg = $GUI_EVENT_CLOSE Or $msg = $SL_Cancel Then

GUIDelete($ServicesList)

Return 0

EndIf

if $msg = ???????? (How can I detect the item change here) then

myFunc

endif

WEnd

thanks a lot.

Link to comment
Share on other sites

  • Moderators

cntour,

Firstly, please do not take this personally, but....

1. It is a lot easier to help if you post working code - having to add a working GUI, etc does not inspire people to help you...

2. Please use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here).

OK, your problem... There are a bunch of functions to help you work with ListViews in the Help file - some of which I have used here:

#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>

$hGUI = GUICreate("Test", 500, 500)

$myList = GUICtrlCreateListView("Name|Description|Status|Startup Type|Log On As", 10, 15, 550, 300)
$LVItem1 = GUICtrlCreateListViewItem("Name1" & "|" & "Des1" & "|" & "Status1" & "|" & "StartType1" & "|" & "LogOnAs1", $myList)
$LVItem2 = GUICtrlCreateListViewItem("Name2" & "|" & "Des2" & "|" & "Status2" & "|" & "StartType2" & "|" & "LogOnAs2", $myList)

GUISetState()

$sCurr_Selected = ""

While 1
    $msg = GUIGetMsg()
    If $msg = 0 Then ContinueLoop
    If $msg = $GUI_EVENT_CLOSE Then
        GUIDelete($hGUI)
        Exit
    EndIf


    $iIndex = _GUICtrlListView_GetNextItem($myList, -1, 0, 8)
    $sSelected = _GUICtrlListView_GetItemText($myList, $iIndex)
    If $sSelected <> $sCurr_Selected Then
        ConsoleWrite($sSelected & @CRLF)
        $sCurr_Selected = $sSelected
    EndIf

WEnd

I hope this helps you do what you want. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

M23, Thanks a lot.

I didn't know I could include code in

 
. Next time I will follow the rule.

It works, I do appreciate your help.

Cntour

cntour,

Firstly, please do not take this personally, but....

1. It is a lot easier to help if you post working code - having to add a working GUI, etc does not inspire people to help you...

2. Please use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here).

OK, your problem... There are a bunch of functions to help you work with ListViews in the Help file - some of which I have used here:

#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>

$hGUI = GUICreate("Test", 500, 500)

$myList = GUICtrlCreateListView("Name|Description|Status|Startup Type|Log On As", 10, 15, 550, 300)
$LVItem1 = GUICtrlCreateListViewItem("Name1" & "|" & "Des1" & "|" & "Status1" & "|" & "StartType1" & "|" & "LogOnAs1", $myList)
$LVItem2 = GUICtrlCreateListViewItem("Name2" & "|" & "Des2" & "|" & "Status2" & "|" & "StartType2" & "|" & "LogOnAs2", $myList)

GUISetState()

$sCurr_Selected = ""

While 1
    $msg = GUIGetMsg()
    If $msg = 0 Then ContinueLoop
    If $msg = $GUI_EVENT_CLOSE Then
        GUIDelete($hGUI)
        Exit
    EndIf


    $iIndex = _GUICtrlListView_GetNextItem($myList, -1, 0, 8)
    $sSelected = _GUICtrlListView_GetItemText($myList, $iIndex)
    If $sSelected <> $sCurr_Selected Then
        ConsoleWrite($sSelected & @CRLF)
        $sCurr_Selected = $sSelected
    EndIf

WEnd

I hope this helps you do what you want. :D

M23

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...