RE: Listview Item identifiers
- Posted by Tony Steward <lockmaster67 at aol.com> Oct 02, 2002
- 428 views
Hi Rangi, Use these procedures and then simple setLVIndex(LVID, Row) global function getLViItemFromlParam( integer id, integer lv_id ) atom findlv, item findlv = struct_LVFINDINFO( LVFI_PARAM, "", lv_id, 0, 0, 0 ) item = sendMessage( id, LVM_FINDITEM, -1, findlv ) release_mem( findlv ) return item end function -- Can set multiple selections, and first item will be made visible global procedure setLVIndex( integer id, object sel ) integer iItem atom lvitem, VOID if atom(sel) then sel = {sel} end if lvitem = struct_LVITEM( LVIF_STATE, 0, 0, LVIS_SELECTED, LVIS_SELECTED, 0,0,0) for i = length( sel ) to 1 by -1 do iItem = getLViItemFromlParam( id, sel[i] ) store( lvitem, LVITEM_iItem, iItem ) VOID = sendMessage( id, LVM_SETITEMSTATE, iItem, lvitem ) end for VOID = sendMessage( id, LVM_ENSUREVISIBLE, iItem, 0 ) end procedure Thanks Tony Steward totorangi at hotmail.com wrote: > As often happens I managed to solve most of this soon after posting! I > had addLV.. and setLV.. back to front. I mistakenly said that > setLVItemText uses the item Identifier whereas it actually needs the > current row Index. Found a post about LVFINDINFO and so have used this > to create a function called findLVItemIndex that returns the current > item index after being passed an item identifier. Seems to do the trick. > > > However, I would still like to know how to programmatically select and > focus a row in a ListView. > > Rangi > > totorangi at hotmail.com wrote: > > Trying to come to grips with Listviews and have found the archive here > > useful but still have a problem with Identifiers. > > > > I have a listview with several columns of data. I also maintain a > > sequence that duplicates data in the listview plus has additional data. > > I want to programmatically update particular rows in the Listview with > > data from the sequence. > > > > I made the now obvious classic mistake of using the Index returned from > > addLVItem as my key for updating the Listview and it worked until I > > happened to sort the listview. I use setLVItemText and SetLVImage to > > update the Listview and I now see that they need the item Identifier and > > > > > > not the row Index. Problem is then how to get the item's Identifier > > after doing each initial addLVItem. The only way I can find of getting > > an Identifier is with getLVSelected but this assumes that a row is > > selected in the first place. This is not the case after the AddLVItem. > > I have tried a setIndex to programmatically select the row after it is > > added but this doesn't seem to work on ListViews. > > > > Would appreciate tips on this. > > > > Thanks > > Rangi > > > > Also, is it possible to view a whole thread on this list ? Search > > returns useful stuff but I can't find any way of seeing the threads. > > > > Give your hardest tasks to your lasiest workers. They will always find the easiest way to complete it.