ajit Posted January 15, 2009 Share Posted January 15, 2009 Hi I am finding it difficult to use GuiCtrlSetData for GUICtrlCreateListViewItem. I could'nt understand it from the help file. Could someone help me out? $INI = "test.ini" ;$Ini = "C:\SomePath\SomeFile.ini" $aSecs = IniReadSectionNames($Ini) $Main = GUICreate("Test GUI") $Lv = GUICtrlCreateListView("Section|Key|Value",10,10,300, 300) For $I = 1 To Ubound($aSecs) -1 $aVals = IniReadSection($Ini, $aSecs[$I]) For $X = 1 To Ubound($aVals) -1 $sVal = $aSecs[$i] & "|" & $aVals[$x][0] & "|" & $aVals[$x][1] GUICtrlCreateListViewItem($sVal, $Lv) Next Next GUISetState() While 1 If GUIGetMsg() = -3 Then Exit Wend Thanks Ajittest.au3 Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 15, 2009 Share Posted January 15, 2009 (edited) Hi I am finding it difficult to use GuiCtrlSetData for GUICtrlCreateListViewItem. I could'nt understand it from the help file. Could someone help me out? $INI = "test.ini" ;$Ini = "C:\SomePath\SomeFile.ini" $aSecs = IniReadSectionNames($Ini) $Main = GUICreate("Test GUI") $Lv = GUICtrlCreateListView("Section|Key|Value",10,10,300, 300) For $I = 1 To Ubound($aSecs) -1 $aVals = IniReadSection($Ini, $aSecs[$I]) For $X = 1 To Ubound($aVals) -1 $sVal = $aSecs[$i] & "|" & $aVals[$x][0] & "|" & $aVals[$x][1] GUICtrlCreateListViewItem($sVal, $Lv) Next Next GUISetState() While 1 If GUIGetMsg() = -3 Then Exit Wend Thanks Ajit You need to save the Control ID of each ListViewItem you create (I prefer in an array, but it doesn't have to be). When you do GuiCtrlSetData() you will provide the Control ID of the item you want to change. To do that, you must have saved it when you created it. #include <Array.au3> Global $aSecs[4] = [3, "One", "Two", "Three"] Global $aVals[4][2] = [[3, ""], ["Alpha", 1], ["Beta", 2], ["Gamma", 3]] Global $aLVItems[1] = [0] $Main = GUICreate("Test GUI") $Lv = GUICtrlCreateListView("Section|Key|Value", 10, 10, 300, 300) For $I = 1 To UBound($aSecs) - 1 For $X = 1 To UBound($aVals) - 1 $sVal = $aSecs[$I] & "|" & $aVals[$X][0] & "|" & $aVals[$X][1] $iLVItem = GUICtrlCreateListViewItem($sVal, $Lv) _ArrayAdd($aLVItems, $iLVItem); Save the Control ID for future reference Next Next GUISetState() Sleep(5000) ; Change the text in the second item: GUICtrlSetData($aLVItems[2], "My|New|Data") While 1 If GUIGetMsg() = -3 Then Exit WEnd Edit: Added demo. Edited January 15, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ajit Posted January 15, 2009 Author Share Posted January 15, 2009 You need to save the Control ID of each ListViewItem you create (I prefer in an array, but it doesn't have to be). When you do GuiCtrlSetData() you will provide the Control ID of the item you want to change. To do that, you must have saved it when you created it. #include <Array.au3> Global $aSecs[4] = [3, "One", "Two", "Three"] Global $aVals[4][2] = [[3, ""], ["Alpha", 1], ["Beta", 2], ["Gamma", 3]] Global $aLVItems[1] = [0] $Main = GUICreate("Test GUI") $Lv = GUICtrlCreateListView("Section|Key|Value", 10, 10, 300, 300) For $I = 1 To UBound($aSecs) - 1 For $X = 1 To UBound($aVals) - 1 $sVal = $aSecs[$I] & "|" & $aVals[$X][0] & "|" & $aVals[$X][1] $iLVItem = GUICtrlCreateListViewItem($sVal, $Lv) _ArrayAdd($aLVItems, $iLVItem); Save the Control ID for future reference Next Next GUISetState() Sleep(5000) ; Change the text in the second item: GUICtrlSetData($aLVItems[2], "My|New|Data") While 1 If GUIGetMsg() = -3 Then Exit WEnd Edit: Added demo. @PsaltyDS Thanks very much for your help. Works perfect. Thanks again. Regards Ajit Link to comment Share on other sites More sharing options...
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