Jump to content

Recommended Posts

Posted

Greetings to all,

I am having some problems with a script. I need to be able to color code different lines in a ListView, depending on what is written on that line. I have some code here and I hope it explains what I am looking to do. This is just a shell of what I have, but I can post the entire code if needed. When I update the Listview by putting information on a line, the line might end with *, but other lines do not. I am looking to make the lines that end with * colored red, and the other lines that do not end with * either green or the default Listview color. Any help\suggestions would be appreciated. I did look on the forums and in the help file, but all I can come up with is how to make ALL of the lines a certain color, not just the ones I need.

Thank you!

Byteme

Code:

#include <GUIConstants.au3>
#include <file.au3>
#include <guiedit.au3>
#Include <GuiList.au3>
#Include <GuiListView.au3>
#Include <Date.au3>

Dim $aRecords
Dim $aRecords2
Dim $aRecords3
Dim $dont
Dim $tmp
Dim $path2File
dim $b

$Form1 = GUICreate("Ignore List", 800, 447, @DesktopWidth / 2 - 400, @DesktopHeight / 2 - 223)
If Not FileExists("c:\windows\web\wallpaper\ripple.jpg") Then
    GUISetBkColor(0x153E7E)
    $tmp = 1
Else
    GUICtrlCreatePic("c:\windows\web\wallpaper\ripple.jpg", -1, -1, 800, 447)
EndIf
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel("Servers Currently in Ignore List", 235, 5, 300, 27)
If $tmp = 1 Then
    GUICtrlSetBkColor(-1, 0x153E7E)
Else
    GUICtrlSetBkColor(-1, 0x38ACEC)
EndIf
GUICtrlSetFont(-1, 17)
If $tmp = 1 Then
    GUICtrlSetColor(-1, 0xE0FFFF)
EndIf
$list1 = GUICtrlCreateListView("ServerName|GroupWhoAdded|DateAdded|BlackoutTimeLimit|Time2BeUp|Exceeded", 10, 40, 780, 300)
_GUICtrlListViewSetColumnWidth($list1, 0, 150)
_GUICtrlListViewSetColumnWidth($list1, 1, 150)
_GUICtrlListViewSetColumnWidth($list1, 2, 150)
_GUICtrlListViewSetColumnWidth($list1, 3, 105)
_GUICtrlListViewSetColumnWidth($list1, 4, 150)
_GUICtrlListViewSetColumnWidth($list1, 5, 70)



;  in original script, only one guictrllistviewinsertitem.
; the script reads a file to an array.  the file contains lines like below
; once array is built, it runs one of the insertitems for each one and adds to gui
; some lines end with "*".....if so, I want to make those lines red.
; if the line does not end with "*" i want to make them either green or keep default color...anything but red



_GUICtrlListViewInsertItem($list1, -1, "abc|mygroup1|05/04/2009 10:08:46 am|00:30:00|05/04/2009 10:38:46 am|")
_GUICtrlListViewInsertItem($list1, -1, "def|mygroup2|05/04/2009 10:08:46 am|00:20:00|05/04/2009 10:28:46 am|*")
_GUICtrlListViewInsertItem($list1, -1, "ghi|mygroup6|05/04/2009 10:08:46 am|00:30:00|05/04/2009 10:38:46 am|")
_GUICtrlListViewInsertItem($list1, -1, "jkl|mygroup4|05/04/2009 10:08:46 am|00:20:00|05/04/2009 10:28:46 am|*")
_GUICtrlListViewInsertItem($list1, -1, "mno|mygroup3|05/04/2009 10:08:46 am|00:30:00|05/04/2009 10:38:46 am|")
_GUICtrlListViewInsertItem($list1, -1, "pqr|mygroup8|05/04/2009 10:08:46 am|00:20:00|05/04/2009 10:28:46 am|*")

; these controls do not work at this time....just giving bare coding here....

$add = GUICtrlCreateButton("Add", 230, 350, 81, 33, 0)
$remove2 = GUICtrlCreateButton("Remove", 360, 350, 81, 33, 0)
$save = GUICtrlCreateButton("Save to CSV", 490, 350, 81, 33, 0)
$exit = GUICtrlCreateButton("Exit", 270, 400, 275, 33, 0)


GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $list1
            _GUICtrlListViewSort($list1, $B_DESCENDING, GUICtrlGetState($list1))
        Case Else
EndSelect   
WEnd
  • Moderators
Posted

byteme,

picaxe produced something that might help you here.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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
×
×
  • Create New...