Jump to content

ListView sort after coloring


Recommended Posts

Hi guys,

This problem is absolutely doing my head in, and I can't find a way round it after hours of searching the forum.

The problem is, I want to sort a listview box after using GUICtrlSetBkColor to color-code the boxes depending on the text value; however, after doing the sort the numbers sort perfectly, but the colors remain in their original positions in the listview box....I want the colors to 'follow' the text.

here is a MASSIVELY simplified example of what is happening in my prog. When you press the button, the list 1,2,3 is reversed, but the colors don't move with the data.

I want 1 = red, 2 = yellow, 3 = green all the time, even after sorting.

CODE
#include <GUIConstants.au3>

#Include <GuiListView.au3>

Opt("GUIOnEventMode", 1)

GUICreate("", 259, 445, 193, 115)

GUISetOnEvent($GUI_EVENT_CLOSE, "close")

$lv = GUICtrlCreateListView("number", 10, 10, 236, 386)

GUICtrlCreateListViewItem("1",$lv)

GUICtrlSetBkColor(-1,0xFF0000)

GUICtrlCreateListViewItem("2",$lv)

GUICtrlSetBkColor(-1,0xFFFF00)

GUICtrlCreateListViewItem("3",$lv)

GUICtrlSetBkColor(-1,0x00FF00)

$Button1 = GUICtrlCreateButton("Button1", 10, 405, 236, 31, 0)

GUICtrlSetOnEvent(-1, "Button1Click")

GUISetState(@SW_SHOW)

While 1

Sleep(100)

WEnd

Func Button1Click()

$v_descending = 1

_GUICtrlListViewSort($lv,$v_descending,0)

EndFunc

Func close()

exit

EndFunc

Can this be done?

Thanks in advance!!!!!!!!!

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
Link to comment
Share on other sites

tut. :)

CODE
#include <GUIConstants.au3>

#Include <GuiListView.au3>

Opt("GUIOnEventMode", 1)

GUICreate("", 259, 445, 193, 115)

GUISetOnEvent($GUI_EVENT_CLOSE, "close")

$lv = GUICtrlCreateListView("number", 10, 10, 236, 386)

$1 = GUICtrlCreateListViewItem("1",$lv)

GUICtrlSetBkColor(-1,0xFF0000)

$2 = GUICtrlCreateListViewItem("2",$lv)

GUICtrlSetBkColor(-1,0xFFFF00)

$3 = GUICtrlCreateListViewItem("3",$lv)

GUICtrlSetBkColor(-1,0x00FF00)

$Button1 = GUICtrlCreateButton("Button1", 10, 405, 236, 31, 0)

GUICtrlSetOnEvent(-1, "Button1Click")

GUISetState(@SW_SHOW)

While 1

Sleep(100)

WEnd

Func Button1Click()

$v_descending = 1

_GUICtrlListViewSort($lv,$v_descending,0)

GUICtrlSetBkColor($3,0xFF0000)

GUICtrlSetBkColor($2,0xFFFF00)

GUICtrlSetBkColor($1,0x00FF00)

EndFunc

Func close()

exit

EndFunc

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
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...