Jump to content

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


Recommended Posts

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

  • Moderators

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.

Link to comment
Share on other sites

  • Moderators

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

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.

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

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

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...