Fritterandwaste Posted September 25, 2022 Posted September 25, 2022 I am a bit confused about how to change the contents of one listbox item. I have been trying to use _GuiCtrlIListbox_GetItemData and _GuiCtrlIListbox_SetItemData. Is this correct? I have tried using _GuiCtrlIListbox_GetItemText also. I have code as follows that is intended to replace the first 4 characters of the entry with 5 dashes : $sLbxEntry = _GuiCtrlListbox_GetItemData($gLbxPlayList, $iLstIdx) FnuDebug("Listbox entry no: " & $iLstIdx & ", Listbox error = " & @error & ", Content: " & $sLbxEntry) $sLbxEntry = "-----" & StringMid($sLbxEntry, 5) _GUICtrlListBox_SetItemData($gLbxPlayList, $iLstIdx, $sLbxEntry) ;results of debug: ;DEBUG: Listbox entry no: 3, Listbox error = 0, Content: 0 It would appear that the first line of code is returning "0" yet that listbox entry is clearly populated with text. I suspect I am misunderstanding something very basic?
Fritterandwaste Posted September 25, 2022 Author Posted September 25, 2022 I think I have solved this problem. I will update the thread when complete.
Solution Fritterandwaste Posted September 25, 2022 Author Solution Posted September 25, 2022 Yes, clearly "ItemData" has nothing to do with the string content displayed. Instead _GuiCtrlIListbox_GetItemText and _GuiCtrlIListbox_ReplaceString must be used. It might help if these were named _GuiCtrlIListbox_GetItemString and _GuiCtrlIListbox_SetItemString. This code works: $sLbxEntry = _GuiCtrlListbox_GetText($gLbxPlayList, $iLstIdx) FnuDebug("Listbox entry no: " & $iLstIdx & ", Listbox error = " & @error & ", Content: " & $sLbxEntry) $sLbxEntry = "-----" & StringMid($sLbxEntry, 5); _GUICtrlListBox_ReplaceString($gLbxPlayList, $iLstIdx, $sLbxEntry)
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