RE: setLVItemText Help Please

new topic     » goto parent     » topic index » view thread      » older message » newer message

Derek Parnell wrote:
> ----- Original Message -----
> From: "Tony Steward" <tony at locksdownunder.com>
> To: "EUforum" <EUforum at topica.com>
> Sent: Friday, May 17, 2002 7:42 PM
> Subject: RE: setLVItemText Help Please
> 
> 
> >
> > Derek Parnell wrote:
> > > 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.
> > >
> > >
> > Hi Derek,
> > The first way you suggest seems to me to be the simplest method for me.
> > That is getLVSelected({KeyMainLV, 1}).
> > But I'm still not getting it working properly. It semes getLVItemText
> > counts the 1st LV column as column 1 but I think setLVItemText counts
> > column 1 as zero. Is this correct?
> >
> > My procedure as follows checks text in the first column and changes the
> > text in the second column, but it doesnt change the correct row.
> > This is using KeyGroupSelected - getLVSelected({KeyMainLV, 1})
> >
> >         for i = 1 to length(KeyGroupSelected) do
> >             id = (KeyGroupSelected[i][2])
> >             if equal(ComKeyKey, getLVItemText(KeyMainLV, id, 1)) then
> >                 setLVItemText(KeyMainLV, id, 1, ComKeyData[1])
> >                 trace(1)
> >                 exit
> >             end if
> >         end for
> >
> > So I must still not understand something!
> >
> No, I've got it wrong. The setLVItemText() should be counting from, but 
> it's
> start at zero. I will examine all the LV routines tonight and make them
> consistant.
<snip>

Making them consistant will be good, but that won't solve my problem. 
Using the routine above I still cant seem to set text to the correct 
part of the LV. Description of problem also above.

Tony

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu