1. 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

new topic     » topic index » view message » categorize

2. Re: Listviews & setIndex again

----- 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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu