byteme Posted May 4, 2009 Posted May 4, 2009 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: expandcollapse popup#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 Melba23 Posted May 4, 2009 Moderators Posted May 4, 2009 byteme, picaxe produced something that might help you here. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now