Jump to content

colored ListView items after Sort


Recommended Posts

Hello !

I have a ListView where I have enabled column sorting by using "GUICtrlRegisterListViewSort", when creating the listView I colored the different lines according to content, how can I color the lines after a column sort?

Link to comment
Share on other sites

  • 6 months later...

I think need use "_GUICtrlListView_MapIndexToID" for like that situations but i can't make work that script <_<

#include <GUIConstants.au3>
#include <GuiListView.au3>
#include <array.au3>

$Width = 170
$Height = 250
$Form = GUICreate("FLEXY", $Width, $Height, -1, -1, BitOR($WS_POPUP, $WS_BORDER))

$MenuItem = GUICtrlCreateMenu("Menu")
$MenuItem1 = GUICtrlCreateMenuItem("TEST!", $MenuItem)
$MenuItem2 = GUICtrlCreateMenuItem("Delete user", $MenuItem)
$MenuItem3 = GUICtrlCreateMenuItem("Save users", $MenuItem)
$Separator1 = GUICtrlCreateMenuItem("", $MenuItem, 2)
$MenuItem4 = GUICtrlCreateMenuItem("Exit", $MenuItem)

$Close = GUICtrlCreateLabel("X", $Width - 15, 0, 11, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetCursor(-1, 0)
$Formtitle = GUICtrlCreateLabel(" " & " (Online)", 0, 4, @DesktopWidth, 20, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Formtitlebackground = GUICtrlCreateGraphic(0, 0, @DesktopWidth, 22)
GUICtrlSetBkColor(-1, 0x000000)
$List = GUICtrlCreateListView("test", 0, 23, $Width, 215, $LVS_NOCOLUMNHEADER)
_GUICtrlListView_InsertColumn ($List, 0, "Column 1", $Width - 45)

GUISetState(@SW_SHOW, $Form)
Test()

While 1
    $msg = GUIGetMsg()
    If $msg = $Close Or $msg = $MenuItem4 Then Exit
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;|
    If $msg = $MenuItem1 Then
        Local $Index[_GUICtrlListView_GetItemCount($List) + 1]
        Global $B_DESCENDING[_GUICtrlListView_GetColumnCount ($List)]
        _GUICtrlListView_SimpleSort ($List, $B_DESCENDING, 0)
        For $i = 1 To _GUICtrlListView_GetItemCount($List)
            $Index[$i] = _GUICtrlListView_MapIndexToID($List, $i - 1)
        Next
        GUICtrlSetColor($Index[1], 0xFFFF00)
        GUICtrlSetColor($Index[2], 0xFF0000)
        GUICtrlSetColor($Index[3], 0x00FF00)
        GUICtrlSetColor($Index[4], 0x0000FF)
    EndIf
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;|
WEnd

Func Test()
$Data = "!List||flexy 123[]admin 3[]admin2[]admin"
If StringInStr($Data, "!List||") Then
    $Friendlist = StringSplit($Data, "||", 1)
    $Friendlist2 = StringSplit($Friendlist[2], "[]", 1)
    ;$Onlinelist = StringSplit($Friendlist[4], "***", 1)
    Dim $Listbox[UBound($Friendlist2) ]
    For $i = 1 To UBound($Friendlist2) - 1
        If $Friendlist2[$i] <> "" Then
            _GUICtrlListView_AddItem ($List, $Friendlist2[$i], 0)
        EndIf
    Next
EndIf
EndFunc
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...