lsakizada Posted June 25, 2009 Share Posted June 25, 2009 I want alternate color in List View but I was unable to set it properly. Can someone help to create functions like. _GUICtrlListView_SetItemColor _GUICtrlListView_SetItemBkColor thanks! Be Green Now or Never (BGNN)! Link to comment Share on other sites More sharing options...
water Posted June 25, 2009 Share Posted June 25, 2009 I use the following code to change the color of every second entryGUICtrlCreateListViewItem("itemtext", $hGUIUserList) If Mod($iRec, 2) = 0 Then GUICtrlSetBkColor(-1, 0xD0DEC7) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
lsakizada Posted June 25, 2009 Author Share Posted June 25, 2009 (edited) I use the following code to change the color of every second entryGUICtrlCreateListViewItem("itemtext", $hGUIUserList) If Mod($iRec, 2) = 0 Then GUICtrlSetBkColor(-1, 0xD0DEC7) Thanks for the rely, it is not working for me. I found this thread which helped me: http://www.autoitscript.com/forum/index.ph...mp;#entry675962 Edited June 25, 2009 by lsakizada Be Green Now or Never (BGNN)! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 25, 2009 Moderators Share Posted June 25, 2009 (edited) lsakizada,The syntax for alternate coloured ListViews is not easy to get from the Help file:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #Include <GuiListView.au3> $hWin = GUICreate("Alt Coloured ListView", 500, 500, -1, -1) GUISetBkColor(0xCECECE) $hList = GUICtrlCreateListView ("This is an alternate coloured ListView", 10, 10, 480, 480, $LVS_SINGLESEL) ; Set up alt line colouring GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) _GUICtrlListView_SetColumnWidth($hList, 0, $LVSCW_AUTOSIZE_USEHEADER) GUISetState() For $i = 1 to 10 GUICtrlCreateListViewItem("Item " & $i, $hList) ; Set up alt line colouring GUICtrlSetBkColor(-1, 0xCCFFCC) Next While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEndM23Edit: If you really want to customise your ListView then look here. Edited June 25, 2009 by Melba23 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...
RagsRevenge Posted August 18, 2009 Share Posted August 18, 2009 lsakizada, The syntax for alternate coloured ListViews is not easy to get from the Help file:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #Include <GuiListView.au3> $hWin = GUICreate("Alt Coloured ListView", 500, 500, -1, -1) GUISetBkColor(0xCECECE) $hList = GUICtrlCreateListView ("This is an alternate coloured ListView", 10, 10, 480, 480, $LVS_SINGLESEL) ; Set up alt line colouring GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) _GUICtrlListView_SetColumnWidth($hList, 0, $LVSCW_AUTOSIZE_USEHEADER) GUISetState() For $i = 1 to 10 GUICtrlCreateListViewItem("Item " & $i, $hList) ; Set up alt line colouring GUICtrlSetBkColor(-1, 0xCCFFCC) Next While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEnd M23 Edit: If you really want to customise your ListView then look here. Is it possible to use the alternate background colour when using _GuiCtrlListview_AddArray? I can't figure it out, seeing as I'm not creating individual listviewItems, so don't have an ID for assigning background colour to the item. Any help, greatly appreciated. D Link to comment Share on other sites More sharing options...
RagsRevenge Posted August 18, 2009 Share Posted August 18, 2009 Is it possible to use the alternate background colour when using _GuiCtrlListview_AddArray? I can't figure it out, seeing as I'm not creating individual listviewItems, so don't have an ID for assigning background colour to the item. Any help, greatly appreciated. D This is a snippet of what I've tried (which isn't working) This is a snippet from a function which is passed the listview as $control, and the array as $aContent. My fear is that I am misunderstanding the _GUICtrlListView_GetItemParam function. I *think* that it will return the control ID for a listviewItem associated with the specified line. GUICtrlSetFont($control, 11) GUICtrlSetBkColor($control, $GUI_BKCOLOR_LV_ALTERNATE) ;set alternate colours for listviewitems ;GUICtrlSetBkColor($control, 0xFFFFFF) _GUICtrlListView_AddArray($control, $aContent) $numItems = _GUICtrlListView_GetItemCount(GUICtrlGetHandle($control)) - 1 for $i = $numItems to 0 Step -1 $listviewItem = _GUICtrlListView_GetItemParam(GUICtrlGetHandle($control), $i) if $listviewItem Then GUICtrlSetBkColor($listviewItem, 0xECE9D8) EndIf Next I have this product nearly fully tested so don't want to introduce total unknowns by using the UDF you linked to above. Thanks, D Link to comment Share on other sites More sharing options...
RagsRevenge Posted August 18, 2009 Share Posted August 18, 2009 My fear is that I am misunderstanding the _GUICtrlListView_GetItemParam function. I *think* that it will return the control ID for a listviewItem associated with the specified line. So, I *think* I misunderstood waht _GUICtrlListView_GetItemParam does. In its stead, I'm using _GUICtrlListView_MapIndexToID GUICtrlSetFont($control, 11) GUICtrlSetBkColor($control, $GUI_BKCOLOR_LV_ALTERNATE) ;set alternate colours for listviewitems ;GUICtrlSetBkColor($control, 0xFFFFFF) _GUICtrlListView_AddArray($control, $aContent) $numItems = _GUICtrlListView_GetItemCount(GUICtrlGetHandle($control)) - 1 for $i = $numItems to 0 Step -1 $listviewItem = _GUICtrlListView_MapIndexToID(GUICtrlGetHandle($control), $i) if $listviewItem Then GUICtrlSetBkColor($listviewItem, 0xECE9D8) EndIf Next But for some reason, my listview is remaining unchanged, and a couple of totally unrelated labels are having their background set. Any help greatly appreciated, and apologies for the ongoing soliloquy. D Link to comment Share on other sites More sharing options...
Gideon Posted March 29, 2011 Share Posted March 29, 2011 Why did I need to google this, because color was removed in the query? Many times you need to think like hobby-bob:') 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