Paradox Community

Items in pnews.paradox-programming

Subject:Re: Listbox Selection
Date:27 May 2019 00:09:14 -0400
From:"Kevin Zawicki" <numberjack@wi.rr.com>
Newsgroups:pnews.paradox-programming



Is this a field where type is list?

many ways to do this:
if you want to find the item:

(from pushbutton, but can be done from anywhere)

method pushButton(var eventInfo Event)
 var
  uiList         uiObject
  MySearchValue  string
  cnt            smallInt
  fnd            logical
 endvar


 MySearchValue = "two"
 fnd = false

 uiList.attach(myList)
 uiList.attach(uiList.first)  ; attach to list under the field

 for cnt from 1 to uiList.list.count
  uiList.list.selection = cnt
  if uiList.list.value = MySearchValue then
   fnd = true
   quitloop
  endif
 endfor


 if fnd = true then 
   cnt.view("list # item")
 endif

endMethod



If you are trying to set the list selection to a value you can set the field
value. Remember the field value and list selection may be different if field
is uncommitted.

I find it is best to actually name the list object under the field and refer
to that, can skip the UI attach.

Also, if the list is not very dynamic I often load an array and fill the
list in same order as array. Yo can then read list value and use an array
for many things.
A field list has 3 properties:
count
selection
value

count is how many in list, but also you can set count to change the list
data set size (not the screen size).


also the list selection can be seen on screen, you can use delay updates
on and off to hide scanning a list.



Kevin Baker <shcsbaker@gmail.com> wrote:
>Hi Everyone!
>
>Is there another way to find an item in a listbox, then highlight 
>(select) than item, other than the way I'm doing it below:
>
>var
>    varid smallInt
>    varName string
>    loFound logical
>endvar
>
>loFound=False
>MyList.MyList_List.action(MoveBeginLine)  ;start at the top
>
>varid=0
>
>While loFound=False
>    varid=varid+1
>    MyList_List.list.selection=varid  ;get the number of the current item
>    varName=MyList_List.list.value    ;put list name in the var
>
>    if varListName="MySearchValue" then  ;is this what I'm looking for?
>       MyList_List.list.selection=varid
>       loFound=True
>    else
>       loop
>    endif
>endWhile
>
>Thanks,
>Kevin


Copyright © 2004 thedbcommunity.com