Jump to content

Changing contents of a listbox item


 Share

Go to solution Solved by Fritterandwaste,

Recommended Posts

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?

Link to comment
Share on other sites

  • Solution

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)

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...