1. Listviews & setIndex again
- Posted by Tony Steward <lockmaster67 at aol.com> Apr 11, 2003
- 432 views
Hello All, Below is how I have always set index in a listview which works fine until I click on a column header and re sort the LV. Any Ideas Anyone Thanks Tony Steward for i = 1 to getLVCount(myLV) do tempText = upper(getLVItemText(myLV, i, 1)) if match(SearchText, tempText) then setLVIndex(myLV, i) exit end if end for 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
2. Re: Listviews & setIndex again
- Posted by Derek Parnell <ddparnell at bigpond.com> Apr 13, 2003
- 400 views
----- Original Message ----- From: "Tony Steward" <lockmaster67 at aol.com> To: "EUforum" <EUforum at topica.com> Subject: Listviews & setIndex again > > Hello All, > Below is how I have always set index in a listview which works fine > until I click on a column header and re sort the LV. > > Any Ideas Anyone > Thanks > Tony Steward > > for i = 1 to getLVCount(myLV) do > tempText = upper(getLVItemText(myLV, i, 1)) > if match(SearchText, tempText) then > setLVIndex(myLV, i) > exit > end if > end for > > 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 > I think that the problem is that win32lib does not try to automatically reselect the currently selected item after the list has been resorted. I'll try to see if this can be done without too much effort. Remember that what is being selected is not the item itself, but the row that the item appears in. I'm not sure how this effects non REPORT-MODE lists. ---------------- cheers, Derek Parnell