1. Win32Lib ListView + setUserProperty query
- Posted by Dave Probert <zingo at purpletiger.com> Jul 11, 2005
- 529 views
Hi All, I've been using listviews (LV) for a while with win32lib and usually I use setUserProperty (SUP) for each row with my hidden data (often sequence information). In my current application I've got an LV which is updated often from queries to a DB and the data row identifier is SUP'd each time. I use eraseItems() followed by loops of addLVItem() and SUP. But, for some reason, after a few rebuilds the userProperty vanishes - as in getUserProperty returns nothing. The first few times everything works perfectly and the code doesn't change, but it seems just to forget about the hidden data! I've pored over the win32lib.ew code and can see nothing wrong in it, and my code is the same as I've used many times before with success. Has anyone else come across this sort of problem either with ListViews or TreeViews? Sorry but the full code is waaaay to big to post here, but here's the lines that fill the listview:
-- loclv is the ListView -- data is a sequence of values for a row -- ids is a matching sequence containing the DB row id's eraseItems(loclv) tmph = 0 for i=length(data) to 1 by -1 do id = addLVItem(loclv,tmph,data[i]) -- add row at a time if i<= length(ids) then setUserProperty(id,"identifier",ids[i]) end if end for
I would use setLVUserProperty, but the row id's are often character strings. Cheers, Dave PS. Derek - looking forward to the next win32lib :) . .. : :: = == == = :: : .. . Server-Side DB driven web sites, Software Development (and part-time games developer) contact dave_p at purpletiger dot com or probert.dave at gmail dot com . .. : :: = == == = :: : .. .
2. Re: Win32Lib ListView + setUserProperty query
- Posted by Derek Parnell <ddparnell at bigpond.com> Jul 11, 2005
- 495 views
- Last edited Jul 12, 2005
Dave Probert wrote: [snip] > Sorry but the full code is waaaay to big to post here, but > here's the lines that fill the listview: > > -- loclv is the ListView > -- data is a sequence of values for a row > -- ids is a matching sequence containing the DB row id's > > eraseItems(loclv) > tmph = 0 > for i=length(data) to 1 by -1 do > id = addLVItem(loclv,tmph,data[i]) -- add row at a time > if i<= length(ids) then > setUserProperty(id,"identifier",ids[i]) > end if > end for > The 'id' in the setUserProperty() call is meant to be a CONTROL and not the value returned by addLVItem(). It is designed to add a property to a control. Another method you might like to look at instead is ...
eraseItems(loclv) tmph = 0 for i=length(data) to 1 by -1 do id = addLVItem(loclv,tmph,data[i]) -- add row at a time if i<= length(ids) then setUserProperty(loclv,id&"identifier",ids[i]) end if end for
And then to retrieve the hidden data for a particular id ...
sequence temp sequence hidden temp = getUserProperty(loclv, id&"identifier") if length(temp) > 0 then hidden = temp[1] else hidden = {} end if
> > PS. Derek - looking forward to the next win32lib :) Me too. -- Derek Parnell Melbourne, Australia irc://irc.sorcery.net:9000/euphoria
3. Re: Win32Lib ListView + setUserProperty query
- Posted by Dave Probert <zingo at purpletiger.com> Jul 12, 2005
- 490 views
Derek Parnell wrote: > > Dave Probert wrote: > > [snip] > > > Sorry but the full code is waaaay to big to post here, but > > here's the lines that fill the listview: > > > > -- loclv is the ListView > > -- data is a sequence of values for a row > > -- ids is a matching sequence containing the DB row id's > > > > eraseItems(loclv) > > tmph = 0 > > for i=length(data) to 1 by -1 do > > id = addLVItem(loclv,tmph,data[i]) -- add row at a time > > if i<= length(ids) then > > setUserProperty(id,"identifier",ids[i]) > > end if > > end for > > > > The 'id' in the setUserProperty() call is meant to be a CONTROL and not the > value returned > by addLVItem(). It is designed to add a property to a control. Another method > you might > like to look at instead is ... > > }}} <eucode> -- loop through current LVITEM ids and remove the associated UserProperties here > eraseItems(loclv) > tmph = 0 > for i=length(data) to 1 by -1 do > id = addLVItem(loclv,tmph,data[i]) -- add row at a time > if i<= length(ids) then > setUserProperty(loclv,id&"identifier",ids[i]) > end if > end for > </eucode> {{{ Ah, thanks - that makes more sense. I kinda get confused with the Control (handles) and Indexes,etc that are returned by the various functions associated with Listviews, Treeviews and Droplists. I guess that it would be sensible to insert a routine to remove the old UserProperties just before the eraseItems() so that the userProps internal list doesn't fill up with junk. > > And then to retrieve the hidden data for a particular id ... > > }}} <eucode> > sequence temp > sequence hidden > temp = getUserProperty(loclv, id&"identifier") > if length(temp) > 0 then > hidden = temp[1] > else > hidden = {} > end if > </eucode> {{{ > Thanks again Derek. I guess I'd better go back through all my old code and fix it ;) Cheers, Dave . .. : :: = == == = :: : .. . Server-Side DB driven web sites, Software Development (and part-time games developer) contact dave_p at purpletiger dot com or probert.dave at gmail dot com . .. : :: = == == = :: : .. .