Jump to content
Sign in to follow this  

Setting Listviewitem background colour

Recommended Posts

I have a listview of machine names, and am trying to change the colour of the listview item based on the outcome of the ping result as shown below:

The listbox is populated from another query with machine names.

Basically want the background colour of the listviewitem to change once the ping select statement has run on each listed item(Machine name) in the listview?

$COLLISTBOX = GUICtrlCreateList("", 305, 150, 210, 133)

$Listcontents = _display_list_items($COLLISTBOX)

$Array = StringSplit($Listcontents, "|")

;Clear and Update the main edit box

;Delete first element of Array      
_ArrayDelete($Array, 0)     
    For $Arraydata In $Array            

         $Pingrslt = Ping($Arraydata, 3000)
        $Errmsg = @error

                Case $Errmsg = 0
                    GUICtrlSetData($COLLECTIONEDIT, $Arraydata & " is online" & @CRLF, 1)       

                Case $Errmsg = 1
                    GUICtrlSetData($COLLECTIONEDIT, $Arraydata & " is offline" & @CRLF, 1)
                Case $Errmsg = 2
                    GUICtrlSetData($COLLECTIONEDIT, $Arraydata & " is unreachable" & @CRLF, 1)

                Case $Errmsg = 3
                    GUICtrlSetData($COLLECTIONEDIT, $Arraydata & " has a bad destination address" & @CRLF, 1)
                Case $Errmsg = 4
                    GUICtrlSetData($COLLECTIONEDIT, "Ping request could not find host " & $Arraydata & ". Please check the name and try again." & @CRLF, 1)     


Func _display_list_items($a_listctrl)
    For $i = 0 To _GUICtrlListCount($a_listctrl) - 1
        If $i = 0 Then
            $listctrl_content = _GUICtrlListGetText($a_listctrl, $i)
            $listctrl_content = $listctrl_content & '|' & _GUICtrlListGetText($a_listctrl, $i)
    Return $listctrl_content
EndFunc   ;==>_display_list_items

Any ideas?


Share this post

Link to post
Share on other sites

^ bump


The only way you can do this is to handle the custom draw notification message from the list view and draw the items yourself. Arcker was working with this using Auto3Lib, so you might want to see how far he got.

Auto3Lib: A library of over 1200 functions for AutoIt

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...