devrandom Posted February 13, 2011 Share Posted February 13, 2011 Hello, how I can change the color of a line of a List control? GUICreate("", 500, 500) $l = GUICtrlCreateList("item1", 1, 1, 498, 498) GUICtrlSetData($l, "item2") - i want to set the color of this line of the list - Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 13, 2011 Moderators Share Posted February 13, 2011 devrandom,You would need an ownerdrawn list to do that - a lot of work. But here is a workaround using labels and my GUIScrollBars_Ex UDF (look in my sig) - just click on a line to change the colour: expandcollapse popup#include <GUIConstantsEx.au3> #Include <GuiScrollBars_Ex.au3> Global $iItems = 50 ; Number of items in list Global $iDisplayItems = 20 ; Number of items in GUI Global $aLabelID[$iItems] ; ControlIDs of labels Global $aData[$iItems][2] ; Data and colour state of labels ; Fill data array For $i = 0 To UBound($aData) - 1 $aData[$i][0] = $i & " - " & $i & " - " & $i & " - " & $i ; Data $aData[$i][1] = 0 ; State Next ; Create GUI $hGui = GUICreate("Scroll Colour Line List", 420, 20 + $iDisplayItems * 20) ; Create "list" For $i = 0 To $iItems - 1 $aLabelID[$i] = GUICtrlCreateLabel($aData[$i][0], 10, 10 + ($i * 20), 380, 20) Next GUISetState() ; Generate scrollbars _GUIScrollbars_Generate($hGui, 0, 4 + ($iItems * 20)) ; Just this one line is all you need to get scrollbars !!!!!!!!!!!!!!!!!!!!!!!!!! While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit ; Click on label so change colour Case $aLabelID[0] To $aLabelID[19] $iIndex = $iMsg - $aLabelID[0] ; Toggle colour data $aData[$iIndex][1] = Not $aData[$iIndex][1] ; Change line colour Switch $aData[$iIndex][1] Case 0 GUICtrlSetColor($aLabelID[$iIndex], 0x000000) Case 1 GUICtrlSetColor($aLabelID[$iIndex], 0xFF0000) EndSwitch EndSwitch WEndAny use? M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
devrandom Posted February 13, 2011 Author Share Posted February 13, 2011 This is what I was looking for. Thank you Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 13, 2011 Moderators Share Posted February 13, 2011 devrandom, Glad I could help. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now