You are not logged in.

Roger L

Beginner

  • "Roger L" started this thread

Posts: 24

Date of registration: Apr 12th 2010

  • Send private message

1

Sunday, May 9th 2010, 1:05am

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!

Roger L

Beginner

  • "Roger L" started this thread

Posts: 24

Date of registration: Apr 12th 2010

  • Send private message

2

Sunday, May 9th 2010, 1:55am

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!

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

3

Sunday, May 9th 2010, 11:39am

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

Roger L

Beginner

  • "Roger L" started this thread

Posts: 24

Date of registration: Apr 12th 2010

  • Send private message

4

Sunday, May 9th 2010, 12:18pm

Many Thanks - I'll give that a go on my return from holiday - back in 2 weeks!



Roger L

Roger L

Beginner

  • "Roger L" started this thread

Posts: 24

Date of registration: Apr 12th 2010

  • Send private message

5

Sunday, May 9th 2010, 12:30pm

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

Roger L

Beginner

  • "Roger L" started this thread

Posts: 24

Date of registration: Apr 12th 2010

  • Send private message

6

Sunday, May 9th 2010, 12:36pm

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

Rate this thread
WoltLab Burning Board