Sign in to follow this  
Followers 0
pootie tang

Any way to have different text color for items in a listview

6 posts in this topic

#1 ·  Posted (edited)

I have a listview (2 columns) which I want to from time to time change the text in 1 given item in column #2. For example,

Column 1.................................................................Column2

My description...........................................................Initial Value (in black)

after the change

My description............................................................New Value (in red)

All other data in the listview (include font color should remains as is). Any help would be appreicated.

On a different note, I have asked the moderators to change my id (to remove confusion with others) ... have not heard back yet.

Dave

Edited by bigdaddy

Share this post


Link to post
Share on other sites



This should give you an idea.

#include <GuiConstants.au3>
#include <GuiListView.au3>

$GUI = GUICreate("Test")
$List = GUICtrlCreateListView("Column 1|Column 2", _
        10, 10, 380, 380, -1, $LVS_EX_FULLROWSELECT)
_GUICtrlListViewSetColumnWidth($List, 0, 190)
_GUICtrlListViewSetColumnWidth($List, 1, 190)
GUISetState()

For $i = 1 To 20
    GUICtrlCreateListViewItem("My description " & $i & "|" & "Initial Value " & $i, $List)
    If $i = 5 Then
        GUICtrlSetColor(-1, 0x0000FF)
    ElseIf $i = 10 Then
        GUICtrlSetColor(-1, 0xFF0000)
    EndIf
Next

While GUIGetMsg() <> $GUI_EVENT_CLOSE
    Sleep(10)
WEnd

p.s. The only mod around right now is jpm. Larry and JdeB are both on vacation.

Share this post


Link to post
Share on other sites

Only Jon can change the name anyway... PM him.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

This should give you an idea.

#include <GuiConstants.au3>
#include <GuiListView.au3>

$GUI = GUICreate("Test")
$List = GUICtrlCreateListView("Column 1|Column 2", _
        10, 10, 380, 380, -1, $LVS_EX_FULLROWSELECT)
_GUICtrlListViewSetColumnWidth($List, 0, 190)
_GUICtrlListViewSetColumnWidth($List, 1, 190)
GUISetState()

For $i = 1 To 20
    GUICtrlCreateListViewItem("My description " & $i & "|" & "Initial Value " & $i, $List)
    If $i = 5 Then
        GUICtrlSetColor(-1, 0x0000FF)
    ElseIf $i = 10 Then
        GUICtrlSetColor(-1, 0xFF0000)
    EndIf
Next

While GUIGetMsg() <> $GUI_EVENT_CLOSE
    Sleep(10)
WEnd

p.s. The only mod around right now is jpm. Larry and JdeB are both on vacation.

Thanks ... I'll give it a shot ... I already PM'ed Jon ... haven't heard back yet

Regards,

Dave

Share this post


Link to post
Share on other sites

This should give you an idea.

#include <GuiConstants.au3>
#include <GuiListView.au3>

$GUI = GUICreate("Test")
$List = GUICtrlCreateListView("Column 1|Column 2", _
        10, 10, 380, 380, -1, $LVS_EX_FULLROWSELECT)
_GUICtrlListViewSetColumnWidth($List, 0, 190)
_GUICtrlListViewSetColumnWidth($List, 1, 190)
GUISetState()

For $i = 1 To 20
    GUICtrlCreateListViewItem("My description " & $i & "|" & "Initial Value " & $i, $List)
    If $i = 5 Then
        GUICtrlSetColor(-1, 0x0000FF)
    ElseIf $i = 10 Then
        GUICtrlSetColor(-1, 0xFF0000)
    EndIf
Next

While GUIGetMsg() <> $GUI_EVENT_CLOSE
    Sleep(10)
WEnd

p.s. The only mod around right now is jpm. Larry and JdeB are both on vacation.

I gave it a shot ... worked perfectly. The only issue I ran into was if another window covered my window and then went away, the colors where lost. As long as another window didn't cover my window, it was ok. Any thoughts? Thanks.

Dave

p.s. id has been changed to pootie tang

Share this post


Link to post
Share on other sites

Is there any way to set color based on index (not ControlID)?

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