Jump to content
water

Alternate color Listview items

Recommended Posts

water

As I have been struggling a bit with the way $GUI_BKCOLOR_LV_ALTERNATE works (couldn't find an example in the help file or the forum) I post a reproducer script for future reference so you can see how it works:

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>

GUICreate("listview items", 220, 250, 100, 200, -1)
Local $idListview = GUICtrlCreateListView("col1  |col2|col3  ", 10, 10, 200, 150)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) ; alternate between the listview background color and the listview item background color
GUICtrlSetBkColor(-1, 0xDDEEFF) ; Set the background color for the listview
Local $idItem1 = GUICtrlCreateListViewItem("item1|col12|col13", $idListview)
GUICtrlSetBkColor(-1, 0xFCF6EA) ; Set the background color for the listview item
Local $idItem2 = GUICtrlCreateListViewItem("item2|col22|col23", $idListview)
GUICtrlSetBkColor(-1, 0xFCF6EA) ; Set the background color for the listview item
Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview)
GUICtrlSetBkColor(-1, 0xFCF6EA) ; Set the background color for the listview item
Local $idItem4 = GUICtrlCreateListViewItem("item4|col42|col43", $idListview)
GUICtrlSetBkColor(-1, 0xFCF6EA) ; Set the background color for the listview item
Local $idItem5 = GUICtrlCreateListViewItem("item5|col52|col53", $idListview)
GUICtrlSetBkColor(-1, 0xFCF6EA) ; Set the background color for the listview item
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Gives you:
Listview_alternate_color.thumb.png.aaf29

Edited by water
  • Like 2

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

You can even change the color:

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>

GUICreate("listview items", 220, 250, 100, 200, -1)
Local $idListview = GUICtrlCreateListView("col1  |col2|col3  ", 10, 10, 200, 150)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) ; alternate between the listview background color and the listview item background color
GUICtrlSetBkColor(-1, 0xDDEEFF) ; Set the background color for the listview
Local $idItem1 = GUICtrlCreateListViewItem("item1|col12|col13", $idListview)
GUICtrlSetBkColor(-1, 0xFCF6EA) ; Set the background color for the listview item
Local $idItem2 = GUICtrlCreateListViewItem("item2|col22|col23", $idListview)
GUICtrlSetBkColor(-1, 0xFCF6EA) ; Set the background color for the listview item
Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview)
GUICtrlSetBkColor(-1, 0xFCF6EA) ; Set the background color for the listview item
Local $idItem4 = GUICtrlCreateListViewItem("Now|change|color", $idListview)
GUICtrlSetBkColor(-1, 0xBBF6EA) ; Set the background color for the listview item
Local $idItem5 = GUICtrlCreateListViewItem("item5|col52|col53", $idListview)
GUICtrlSetBkColor(-1, 0xBBF6EA) ; Set the background color for the listview item
Local $idItem5 = GUICtrlCreateListViewItem("item6|col62|col63", $idListview)
GUICtrlSetBkColor(-1, 0xBBF6EA) ; Set the background color for the listview item
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Listview_alternate_color.thumb.png.94b8a

  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Skysnake

Thx Water. :)


Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites
water

I have added an additional example to the repository. Will be available with the next beta.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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

×