Slipk Posted December 20, 2018 Posted December 20, 2018 Hello, I have a listview with 3 items and I have to change background color from first to last with a sleep of one second between them. How to do that if the items are not called? they are dynamic. *I know how to change the background color of the item, just how to use For , To , Next in order to identify them from the first to the last one. Thank you , sry for my bad english.
FrancescoDiMuro Posted December 20, 2018 Posted December 20, 2018 @Slipk We ain't have crystal ball, so, if you could please post your script, we can see how we can help you Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Slipk Posted December 20, 2018 Author Posted December 20, 2018 #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> Global $value = 3 $Form1 = GUICreate("Form1", 605, 331, -1, -1) $ListView1 = GUICtrlCreateListView("#|Example", 0, 0, 602, 262) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150) $Button1 = GUICtrlCreateButton("create", 16, 280, 75, 25) $Button2 = GUICtrlCreateButton("go", 116, 280, 75, 25) GUISetState(@SW_SHOW, $Form1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 For $i = 1 To $value GUICtrlCreateListViewItem("item" & $i & "|" & "example", $ListView1) Next Case $Button2 For $i = 0 To _GUICtrlListView_GetItemCount($ListView1) Sleep(1000) ;change for every item background color Next EndSwitch WEnd Hello, Thank you for your help! When you click $Button1 it creates how many listview items I want. When the user click $Button2 I want to wait one second and change background to all items until it reach the last one.
FrancescoDiMuro Posted December 20, 2018 Posted December 20, 2018 (edited) @Slipk One of many ways expandcollapse popup#include <ButtonConstants.au3> #include <ColorConstants.au3> ; Added #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> Global $value = 3, _ $arrItemIDs[$value], _ ; Added $intItemColor ; Added $Form1 = GUICreate("Form1", 605, 331, -1, -1) $ListView1 = GUICtrlCreateListView("#|Example", 0, 0, 602, 262) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150) $Button1 = GUICtrlCreateButton("create", 16, 280, 75, 25) $Button2 = GUICtrlCreateButton("go", 116, 280, 75, 25) GUISetState(@SW_SHOW, $Form1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 For $i = 0 To $value - 1 ; Changed $i from 1 to 0 $arrItemIDs[$i] = GUICtrlCreateListViewItem("item" & $i & "|" & "example", $ListView1) ; Added Next Case $Button2 ; Added For $i = 0 To UBound($arrItemIDs) - 1 Step 1 ; Sleep(1000) ;change for every item background color If Mod($i, 2) = 0 Then $intItemColor = $COLOR_YELLOW Else $intItemColor = $COLOR_SILVER EndIf GUICtrlSetBkColor($arrItemIDs[$i], $intItemColor) Next EndSwitch WEnd Edited December 20, 2018 by FrancescoDiMuro Slipk 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
FrancescoDiMuro Posted December 20, 2018 Posted December 20, 2018 @Slipk Happy to have helped Slipk 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
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