Jump to content

Recommended Posts

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
Posted

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
Posted

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.

Posted

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.

Posted

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!

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
×
×
  • Create New...