Jump to content

How to set the background color of a listview item created with _GUICtrlListView?


Recommended Posts

Is it possible to set the background color of an individual Listview item created by the _GUICtrlListView functions?

Where's

_GUICtrlListView_SetItemBkColor and _GUICtrlListView_SetItemTextColor ?

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <Constants.au3>


GUICreate("ListView Set BkColor", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
GUISetState()

; Set colors
_GUICtrlListView_SetBkColor($hListView, $CLR_MONEYGREEN)
_GUICtrlListView_SetTextColor($hListView, $CLR_BLACK)
_GUICtrlListView_SetTextBkColor($hListView, $CLR_MONEYGREEN)

; Add columns
_GUICtrlListView_AddColumn($hListView, "Items", 100)

; Add items
_GUICtrlListView_BeginUpdate($hListView)
For $iI = 1 To 10
    $iItem = _GUICtrlListView_AddItem($hListView, "Item " & $iI)
    
    If Mod($iI, 2) Then
;_GUICtrlListView_SetItemBkColor($hListView, $iItem, 0xc0c0c0); Could such a function exist?
    Else
;_GUICtrlListView_SetItemBkColor($hListView, $iItem, 0xffffff) 
    EndIf
Next
_GUICtrlListView_EndUpdate($hListView)

; Show clors
MsgBox(4160, "Information", _
        "Back Color ....: " & _GUICtrlListView_GetBkColor($hListView) & @CRLF & _
        "Text Color ....: " & _GUICtrlListView_GetTextColor($hListView) & @CRLF & _
        "Text Back Color: " & _GUICtrlListView_GetTextBkColor($hListView))

; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
Edited by Kastout
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

http://www.autoitscript.com/forum/index.ph..._NOTIFYITEMDRAW

GUiCtrlListView and the $GUI_BKCOLOR_LV_ALTERNATE

Alternating row background color?, _GUICtrlListView_Create

http://www.autoitscript.com/forum/index.ph...mp;#entry470173

I guess I was being optimistic in thinking this was a simple matter of single function call.

Regardless, thanks for the info.

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

I suppose this method draws the background color/text color as it is created or "drawn" thus it can't be changed later on?

I need to change the background after an item has been created, or on the fly if you will, I wish I understood how this worked, but I don't. :mellow:

Something like _GUICtrlListView_SetItemBkColor() would be nice.

Too sum up I need the same functionality of GUICtrlCreateListViewItem() and GUICtrlSetBKColor() with the _GUICtrlListView_ functions

Edited by Kastout
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
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...