RE: setLVItemText Help Please
- Posted by Derek Parnell <ddparnell at bigpond.com> May 15, 2002
- 382 views
Tony Steward wrote: > Hi Derek or anyone who can help, > When I try to change the contents of part of my LV it just doesn't seem > to work. Hi Tony, there are a couple of things to note here. Firstly, getLVItemText() and setLVItemText() use the item's INDEX value. This is the row number where the item is CURRENTLY positioned in the listview. And getLVSelected() returns a list of item IDENTIFIERS, not INDEX values. Each item in a listview is given a unique IDENTIFIER. This is unique for the application, not just that particular listview. This means that no two listview items in your applicaiton have the same ID, even though they might have the same INDEX if they are in different listviews. I don't know why it was written this way, but I decided not to break existing code by changing this default behaviour. What I did do though was to allow you to return an expanded list from getLVSelected(). If you use the form getLVSelected( {KeyMainLV, 1}) you will get a list of items in the form of a 2-element sequence. The first element is the ID and the second is the INDEX. For example you might have row 4 and 6 selected, thus you would get back something like... { {27, 4}, {12, 6} } You can then use the INDEX values returned in getLVItemText and setLVItemText. The second thing to note is that you really should NOT use the value returned by addLVItem as a subscript value. addLVItem returns an item's ID value. An you CANNOT guarentee that these will be sequential or even that they will be > 0. So instead of ... id = KeyMainLVID[KeyGroupSelected[i]] you might use ... id = find(KeyGroupSelected[i], KeyMainLVID) if id != 0 then id = KeyMainLVID[id] else -- msg "Bad ID" end if But note that this doesn't really answer your initial problem. Here is the way to find an item's INDEX for the item's ID .. atom LV_FINDINFO LV_FINDINFO = struct_LVFINDINFO( LVFI_PARAM, "", itemID, 0, 0, 0) itemINDEX = sendMessage( myLV, LVM_FINDITEM, -1, LV_FINDINFO ) + 1 release_mem(LV_FINDINFO) Hopes this helps... ---------- Derek.