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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

list box selecting list item on up/down arrow key 1

Status
Not open for further replies.

CMcC

Programmer
Joined
Feb 5, 2002
Messages
196
Location
US
Hi all-
I am having problems with my listbox selecting items when the page down or up keys are pressed. I want the user to be able to either click, or up/down arrow to select an item.
However, when the user presses down arrow, it selects the item and releases the form.

I have this code:

***List1.keypress
Lparameters nKeyCode, nShiftAltCtrl
If nKeyCode = 13
Thisform.whichpick = Thisform.list1.Value
With Thisform.oForm
.Cancel = Thisform.Cancel
.state = Thisform.whichpick
Endwith
Thisform.Release()
Endif

***list1.click()
Thisform.whichpick = Thisform.list1.Value
With Thisform.oForm
.Cancel = Thisform.Cancel
.state = Thisform.whichpick
Endwith
Thisform.Release()
Now here is what I found....
If I take out the click event, the user is able to scroll down with out selecting and press enter on their choice, but they cannot select by clicking on it.

If I put the click back in, when they hit the up/down arrow, it selects and releases the form.

Any ideas as to why this is happening?
thanks so much in advance
 
click also fires after the selected item changes. Mousedown doesn't work as a replacement for click, as the value then isn't what was clicked on.

Hmm, simply check MDOWN() in the click event and only exit if that returns .T.

Code:
* list1.click
if mdown()
   Thisform.whichpick = Thisform.list1.Value
   With Thisform.oForm
       .Cancel = Thisform.Cancel
       .state = Thisform.whichpick
   Endwith
   Thisform.Release()
endif
 
Hi again,

No that doesn't work.

another form property: lKeypressed

** list1.keypress
thisform.lKeypressed = .T.
...

**list1.click
if !thisform.lKeypressed
...
endif
thisform.lKeypressed = .F.

Bye, Olaf.
 
thank you Olaf. I will try and get back with you.
I was also wondering about something else in this listbox..

If I set the recordsource to a table, and go top upon init, when I scroll down to the end, it seems to 'pop' back up to somewhere like 1/4 down the table. Really strange.

Ever had any problems like that?
thanks again
cmcc
 
Hi CMcC,

No, haven't seen something like this happen. Did you set some order or filter on that table? What did you set RecordsourceType to?

Bye, Olaf.
 
hi Olaf
RecordsourceType = 'alias'

This is what the difference seems to be:
When I open the table with 'noupdate' - down arrow key acts weird.
If I open the table plain, there is no problem.
I just dont want user to be able to change value in the table from the list.

carol
 
Hi Carol,

In a listbox you can't change values, only choose one of the displayed values. So there is no need for "NOUPDATE".

Bye, Olaf.
 
Thanks Olaf.
carol
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top