Sign in to follow this  
Followers 0
RogerL

How do I change text colour of a _GUICtrlListView_AddItem?

8 posts in this topic

#1 ·  Posted (edited)

If I use GUICtrlCreateListViewItem I believe I can change the text colour with GUICtrlSetColor.

How do I change the text colour if I use _GUICtrlListView_AddItem as it returns the index instead of the controlId required by GUICtrlSetColor (and there isn't a _GUICtrlListView_SetItemTextColour function)?

Sorry if this a novice question, I'm still trying to understand the difference between the standard GUIListView funcs and the UDF ones.

Edited by RogerL

Share this post


Link to post
Share on other sites



RogerL

Help rulez :D

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

$Gui = GUICreate("Test", 320, 220)

$hListView = _GUICtrlListView_Create($GUI, "Items|SubItems1|SubItems2", 10, 10, 300, 200, BitOR($LVS_EDITLABELS, $LVS_REPORT), $WS_EX_CLIENTEDGE)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_SUBITEMIMAGES, $LVS_EX_FULLROWSELECT))

_GUICtrlListView_SetColumnWidth($hListView, 0, 98)
_GUICtrlListView_SetColumnWidth($hListView, 1, 98)
_GUICtrlListView_SetColumnWidth($hListView, 2, 98)

_GUICtrlListView_AddItem($hListView, "Item1")
_GUICtrlListView_AddItem($hListView, "Item2")
_GUICtrlListView_AddItem($hListView, "Item3")
_GUICtrlListView_AddItem($hListView, "Item4")

_GUICtrlListView_AddSubItem ($hListView, 0,'44', 1)
_GUICtrlListView_AddSubItem ($hListView, 1,'22', 1)
_GUICtrlListView_AddSubItem ($hListView, 2,'11', 1)
_GUICtrlListView_AddSubItem ($hListView, 3,'33', 1)

_GUICtrlListView_AddSubItem ($hListView, 0,'New', 2)
_GUICtrlListView_AddSubItem ($hListView, 1,'Page', 2)
_GUICtrlListView_AddSubItem ($hListView, 2,'Sys', 2)
_GUICtrlListView_AddSubItem ($hListView, 3,'Device', 2)

_GUICtrlListView_SetTextColor($hListView, $CLR_GREEN)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

RogerL

Help rulez :D

Thanks Rasim, looks nice, but not what I asked for.

I want to know how to change the colour of the text of an individual item or sub-item, (created by the UDF functions), NOT every item and sub-item in the whole list view.

Share this post


Link to post
Share on other sites

Thanks Rasim, looks nice, but not what I asked for.

I want to know how to change the colour of the text of an individual item or sub-item, (created by the UDF functions), NOT every item and sub-item in the whole list view.

If you need each subitem in different color then it's possible only with ownerdraw. Seach for ownerdraw examples on the forum.

Share this post


Link to post
Share on other sites

If you need each subitem in different color then it's possible only with ownerdraw. Seach for ownerdraw examples on the forum.

I'd settle for individual Items (i.e just column 1) if it was easier!

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  
Followers 0