Sign in to follow this  
Followers 0
Jewtus

Change ListView row font color

6 posts in this topic

I'm trying to make it so anything in a row that has a specific column 5 value will show up with red font. Here is a small snippet.

For $z = 0 To (UBound($MetadataDB2)) - 1
    _GUICtrlListView_AddItem($FoundAccountBox, $MetadataDB2[$z][5], 0)
    _GUICtrlListView_AddSubItem($FoundAccountBox, $z, $MetadataDB2[$z][0], 1, 1)
    _GUICtrlListView_AddSubItem($FoundAccountBox, $z, $MetadataDB2[$z][1] & " to " & $MetadataDB2[$z][2], 2, 2)
    _GUICtrlListView_AddSubItem($FoundAccountBox, $z, $MetadataDB2[$z][3], 3, 3)
    If $MetadataDB2[$z][5] <> 0 Then
        MsgBox(0,"","COLOR CHANGE DAMNIT"&@CRLF&$MetadataDB2[$z][5])
        
    EndIf
Next

The message box kicks up for ever time the field is blank, but I don't really know what command will change just a single rows font color. I've been looking at this article:

'?do=embed' frameborder='0' data-embedContent>>

But I cannot seem to figure out how to actually change the font color... Anyone have tips?

Share this post


Link to post
Share on other sites



Jewtus,

As you want to colour the whole line I would do it using the native functions rather than the UDF: :)

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$cLV = GUICtrlCreateListView("Col 0     |Col 1     |Col 2     |Col 3     |Col 4     ", 10, 10, 400, 200)

For $i = 0 To 20
    $iItem_0 = Random(0, 5, 1)
    $iItem_1 = Random(0, 5, 1)
    $iItem_2 = Random(0, 5, 1)
    $iItem_3 = Random(0, 5, 1)
    $iItem_4 = Random(0, 1, 1)
    GUICtrlCreateListViewItem($iItem_0 & "|" & $iItem_1 & "|" & $iItem_2 & "|" & $iItem_3 & "|" & $iItem_4, $cLV)
    If $iItem_4 <> 0 Then
        GUICtrlSetColor(-1, 0xFF0000) ; Colour line if final item in not 0
    EndIf
Next

GUISetState()

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

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Jewtus,

As you want to colour the whole line I would do it using the native functions rather than the UDF: :)

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$cLV = GUICtrlCreateListView("Col 0     |Col 1     |Col 2     |Col 3     |Col 4     ", 10, 10, 400, 200)

For $i = 0 To 20
    $iItem_0 = Random(0, 5, 1)
    $iItem_1 = Random(0, 5, 1)
    $iItem_2 = Random(0, 5, 1)
    $iItem_3 = Random(0, 5, 1)
    $iItem_4 = Random(0, 1, 1)
    GUICtrlCreateListViewItem($iItem_0 & "|" & $iItem_1 & "|" & $iItem_2 & "|" & $iItem_3 & "|" & $iItem_4, $cLV)
    If $iItem_4 <> 0 Then
        GUICtrlSetColor(-1, 0xFF0000) ; Colour line if final item in not 0
    EndIf
Next

GUISetState()

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

 

AWESOME! That is exactly what I needed. I also had no idea that GUICtrlCreateListViewItem would do the function that way... I have those stupid add sub item commands on every list view box!!!! Looks like I got some code to rewrite.

Share this post


Link to post
Share on other sites

Jewtus,

 

Looks like I got some code to rewrite

Sorry about that. :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

The udfs are nice but their usual use often leads to forget many easy-to-use integrated funcs  :)

Edited by mikell

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Can we change color of the specified item without use the value returning from GuiCtrlCreateListViewItem()?

Edited by Adele

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
Sign in to follow this  
Followers 0