Listbox Problem

Post Reply
User avatar
xProgrammer
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Listbox Problem

Post by xProgrammer »

I am using a listbox to enable one of four possible locations to be selected. The current location is read from the database and the listbox selection set to match with code like the following:

Code: Select all

  @3, 45 LISTBOX lbLocations VAR sThisLoc OF dlgPatFile ;
 ITEMS ::aLocName SIZE 180, 110 

   FOR liTry = 1 TO ::nLocs
      IF ::aLocKey[liTry] = ::sFLKey
         lbLocations:nAt   = liTry
      ENDIF
   NEXT
This works but the problem is that if you tab into the listbox the selection changes to the first entry in the listbox. This only happens the first time you tab into it, if you tab through it a second time whatever has been selected remains unchanged. I need a fix or a workaround to prevent or circumvent this behaviour.

Thanks

xProgrammer
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Doug,

We have been trying to fix that behavior without luck yet
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
xProgrammer
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Thanks for effort and advice

Post by xProgrammer »

Antonio

Thanks for your effort and advice. I will start investigating workarounds. But a fix would be highly desirable.

One possibility is to use a get for the current value (read only) plus a listbox and a button labelled "change to" - a bit complex if there are multiple listboxes on the one screen.

I'll try a one column grid although that may behave in the same way.

Thanks

Doug (xProgrammer)
User avatar
xProgrammer
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Tried a 1 column grid

Post by xProgrammer »

Antonio

I tried a 1 column BROWSE. Setting oBrw:nAt worked in the sense that it selected the correct row but it also made that row the top row of the browse - which is not what I want. I haven't yet figured out how to use oBrw:oVScroll to scroll back to the top (hopefully without moving the currently highlighted row).

Thanks

Doug (xProgrammer)
User avatar
xProgrammer
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

A suggestion

Post by xProgrammer »

Antonio

A possible work around might be if the LISTBOX class supported code blocks that were evaluated for the SETFOCUS and LOSTFOCUS events. The we could keep track of the last value and reset it. Not perfect - the screen might flash a bit, but possibly workable.

I also note that it only happens the first time you tab into the listbox, and if you click the mouse on the listbox before tabbing into it, the behaviour doesn't occur.

This suggested that programmatically setting focus to the listbox might solve the problem. I tried that (prior to dialog activation) but it didn't work. Maybe if we could do it in an ON INIT method (and so after dialog activation) that might work.

Maybe one of these approaches will work.

Regards

Doug (xProgrammer)
Post Reply