Dear visitor, welcome to Jabaco - Community.
If this is your first visit here, please read the Help. It explains in detail how this page works.
To use all features of this page, you should consider registering.
Please use the registration form, to register here or read more information about the registration process.
If you are already registered, please login here.
ListBox
Hi,
I'm using a listbox as a lookup on a master file maintenance (add/change/delete) screen. I have the list as just one row high so that I can scroll up and down the primary keys for the records and select which one I want to edit. I can also navigate via forward and backward (and first and last) arrow keys as well. I put in some code to set the index of the listbox so that if the record on the screen changes so does the lookup field as follows :-
List1.ListIndex = recNum
List1.ensureIndexIsVisible 1
What I find is happening is that the correct (ie current) record is being highlighted in the list, but it may be the next one above or below the one actually being displayed. Is this a bug in the 'ensureIndexIsVisible' function, or am I doing something wrong?
Thanks
Roger L
ps Going on holiday to Tasmania tomorrow so I'll give you a rest for 2 weeks!
Further - I tried making the listbox two rows long instead of the one I had before - it then displayed selected key fine except for the last one! The last record key was highlighted, but stayed off the bottom of the lisbox until I scrolled to it. For all other keys the listbox moved to a position in the list where the selected key was visible!
I am using the following code which might be helpful to you:
|
Jabaco Source
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
Private Sub autoSelectList
' select visible list item, unless some other item is selected explicitly
Dim i As Integer
If List1.Parent.getMinSelectionIndex < 0 Then
' nothing selected yet
i = List1.Parent.getFirstVisibleIndex
If i > 0 Then
' select visible list entry
List1.ListIndex = i
End If
Else
i = List1.ListIndex
End If
List1.ensureIndexIsVisible i
List1.ensureIndexIsVisible i
Me.Refresh
End Sub
|
Volunteers for testing, fixing and extending the Jabaco framework are always welcome!
Greetings
A1880
Many Thanks - I'll give that a go on my return from holiday - back in 2 weeks!
Roger L
Couldn't wait - I gave it a go before leaving - I had thought that ensureIndexIsVisible took a value of 1 (true) to be enabled or else it was false ie not enabled - as soon as I used the index of the selected list item as the parameter all was working fine! I can now go on holiday and not keep thinking about it!
Thanks Roger L
Looking at my last reply - it seems a little obvious that one would need to enter the index numberof the list item that has to be visible - what I had assumed was that the currently selected list item was always the one to be made visible.
Roger L