Jump to content

How to set Bk color on specified item in ListView


Recommended Posts

Hi.

I have script with GUIctlrListView, and I want to set different background colors to items.

I searching something similar than this _GUICtrlListView_SetTextBkColor.

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

GUICreate("lol", 400, 400)
$dfgdfgdf = GUICtrlCreateListView("example1|example2|example3", 10, 10, 255, 150)
_GUICtrlListView_SetColumnWidth($dfgdfgdf, 0, 50)
_GUICtrlListView_SetColumnWidth($dfgdfgdf, 1, 50)
_GUICtrlListView_SetColumnWidth($dfgdfgdf, 2, 150)
_GUICtrlListView_AddItem($dfgdfgdf, "army")
_GUICtrlListView_AddSubItem($dfgdfgdf, 0, "23", 1)
_GUICtrlListView_AddSubItem($dfgdfgdf, 0, "55", 2)
_GUICtrlListView_AddItem($dfgdfgdf, "army2")
_GUICtrlListView_AddSubItem($dfgdfgdf, 1, "23", 1)
_GUICtrlListView_AddSubItem($dfgdfgdf, 1, "55", 2)

_GUICtrlListView_SetTextBkColor($dfgdfgdf, 0x00ff00)
GUISetState(@sw_show)

Sleep(5555555555)

With this I have all text backgrounds with green. How can I do that the first item is on white and 2nd on green background? Is this possible?

Link to comment
Share on other sites

How can I do that the first item is on white and 2nd on green background? Is this possible?

Sry, I've seen too late that you only want to set backcolor changing by odd and even rows.

This is vers simple:

#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
GUICreate('Test')

$ListView1 = GUICtrlCreateListView("Col 1|Col 2", 15, 15, 300, 250)
GUICtrlSetBkColor(-1, 0xFF4400) ; Color odd row
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE)
_GUICtrlListView_SetColumnWidth($ListView1, 0, 148)
_GUICtrlListView_SetColumnWidth($ListView1, 1, 148)

For $i = 1 To 30
    GUICtrlCreateListViewItem(Random(10000, 1000000, 1) & '|' & Random(10000, 1000000, 1), $ListView1)
    GUICtrlSetBkColor(-1, 0xFFFF23) ; Color even row
Next

GUISetState()

Do
Until GUIGetMsg() = -3

Best Regards BugFix  

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...