Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List skip one row

Status
Not open for further replies.

ajenat

Programmer
Nov 28, 2007
9
0
0
IN
Hello..
In VFP9, if we press downarrow just when/before creating the list box, the second item is skipped and third item is selected.
SET TALK OFF
clear
DIMENSION myarray(6)
myarray(1)='Ashwani Khurana'
myarray(2)='Aditya Pasricha'
myarray(3)='Arjuna Panday'
myarray(4)='Dalip Kumar'
myarray(5)='Komaljit Kaur'
myarray(6)='Naresh Gupta'
STORE 1 TO my1list,my2list
@2,2 SAY 'my1list'
@2,36 say'my2list'
@15,1 say'Press <TAB> and <DownArrow> as quickly as you can to minimise delay between them.'
@3,1 get my1list from myarray
READ
@16,1 say'In my2list Selection will reach at 3rd item instead of 2nd.'
@3,35 get my2list from myarray
READ time 1
IF my2list=3
@17,1 say'See you press downarrow once but 2nd item skipped.' colo RGB(255,0,0,255,255,255)
else
@17,1 say'Oops, try again.' colo RGB(255,0,0,255,255,255)
ENDIF
* Behaviour remains same in Forms.
 
 https://files.engineering.com/getfile.aspx?folder=3a27fda0-ff8a-40db-a40c-ce64b425cabb&file=Screen.png
Instead of using the TAG property, you could also define a listbox class that has a "LastListIndex" integer properrty and keep track how that sometimes changes by 2 or more to correct it to only skip by 1.

Code:
Define Class _Listbox as Listbox
    LastListIndex = 0

    Procedure ProgrammaticChange()
       This.LastListIndex = This.Listindex
    EndProc

    Procedure InteractiveChange()
       #Define DNARROW 24
       #Define UPARROW 5
       Do Case 
          Case Lastkey()=DNARROW And This.Listindex>This.LastListIndex+1
             This.Listindex = Min(This.Listcount,This.LastListIndex+1)
          Case Lastkey()=UPARROW And This.Listindex<This.LastListIndex-1
             This.Listindex = Max(1,This.LastListIndex-1)       
       EndCase
       This.LastListIndex = This.Listindex
   EndProc
EndDefine

Don't use this as a class definition in a PR, redo that as visual ListBox class in a VCX, add the property LastListIndex and the code ofthe two change events. You can also make the constants part of a header file which you can set to be used for the whole class, though for the moment you only need the constants in the InteractiveCahnge event.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top