coolboy2295 Posted September 27, 2011 Posted September 27, 2011 (edited) Hi, Some body help me how to make list view item have color. I need each list view item have difference color. Thanks for read. Edited September 27, 2011 by coolboy2295
hannes08 Posted September 27, 2011 Posted September 27, 2011 Hello coolboy2295, a good place to start would be the helpfile. Look for the GUICtrlSetColor() function. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
coolboy2295 Posted September 27, 2011 Author Posted September 27, 2011 Oh thanks i could do it now. But how to make the newer list view item on the top.
Moderators Melba23 Posted September 27, 2011 Moderators Posted September 27, 2011 coolboy2295,Use _GUICtrlListView_InsertItem with the $iIndex parameter set to 0. #include <GUIConstantsEx.au3> #include <GuiListView.au3> $hGUI = GUICreate("Test", 400, 250) $hListView = GUICtrlCreateListView("Items", 2, 2, 220, 196) _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE_USEHEADER) GUICtrlCreateListViewItem("Item 1", $hListView) GUICtrlCreateListViewItem("Item 2", $hListView) GUICtrlCreateListViewItem("Item 3", $hListView) _GUICtrlListView_InsertItem($hListView, "New Item", 0) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEndM23 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
coolboy2295 Posted September 27, 2011 Author Posted September 27, 2011 Thanks Melba23, but can we do it with other way. I not prefer using _guictrllistview.
Moderators Melba23 Posted September 27, 2011 Moderators Posted September 27, 2011 coolboy2295,Use an array to store the data and insert the new item at the top. Then clear the ListView and repopulate it each time you add a new item. I not prefer using _guictrllistviewAny particular reason? 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
coolboy2295 Posted September 27, 2011 Author Posted September 27, 2011 Thanks. Can you help me to change ltem width in guictrlcreateview not _guictrllistview.
BrewManNH Posted September 27, 2011 Posted September 27, 2011 You can use _GUICtrlListView_SetColumnWidth to set the width to what you want. If you prefer to not use the GuiListView.au3 UDF (not sure why though), you can do it this way: GUICtrlSendMsg($hWnd, $LVM_SETCOLUMNWIDTH, $iCol, $iWidth) Where $hWnd is the controlID of the listview, $iCol is the column you want to change, and $iWidth is the width you want the column to be in pixels. Use -1 for $iWidth to autosize the column width to the longest item in that column or you can use -2 to resize the column width to match the header text. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
alfa Posted October 6, 2011 Posted October 6, 2011 Use an array to store the data and insert the new item at the top. Then clear the ListView and repopulate it each time you add a new item. I am trying to do this exactly. _GUICtrlListView_AddArray ($hListView, $val) i get this error message C:\Program Files\AutoIt3\Include\GuiListView.au3 (520) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: DllStructSetData($tBuffer, "Text", $aItems[$iI][0]) DllStructSetData($tBuffer, "Text", ^ ERROR What am i doing wrong ?
Zedna Posted October 6, 2011 Posted October 6, 2011 You must use two dimensional array. Invest more time to reading helpfile instead of trying nonsense. Resources UDF ResourcesEx UDF AutoIt Forum Search
Moderators Melba23 Posted October 6, 2011 Moderators Posted October 6, 2011 alfa,Why are you hijacking this thread in the first place? The OP dealt with colouring items in a ListView and you are asking about _GUICtrlListView_AddArray - nothing to do with the original subject. Zedna's answer is absolutely correct - how many dimensions are there in the array you are trying to use? If the answer is not 2 and it is not formatted as explained in the Help file then it is hardly surprising that it does not work. If it is a suitably formatted array then post your code so we can try to debug it. You appear not to have done the first of those things as you have a simple error which suggests that you do not have a 2D array. And you have not done the second as I see no code in your post. How can we help you if we do not know what you have done? If you do not respect the rules of the forum you are likely to get short shrift - as has just been demonstrated. So over to you - either use an array of the correct format or post your script so we can debug. 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
alfa Posted October 6, 2011 Posted October 6, 2011 I wasnt trying to hijack anyones thread , i just saw that one of the answers was really similar to mine and didnt want to go for a new post. I will make a new post than.
Moderators Melba23 Posted October 6, 2011 Moderators Posted October 6, 2011 alfa,I will make a new postGood idea. But read what I posted above and give us more to go on than a simple error message or you are likely to get a similar response! 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