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

Scroll a listbox control? 2

Status
Not open for further replies.

lachesis

Technical User
Sep 25, 2002
138
NZ
Anyone know how to scroll a listbox control to the row index of the 'first' selected value??

For example, a listbox with 200 items, displays 8 items at any one time (scrollbar down side):

Selected items at (say) row# 99, 140, 150, and 155. I do not want to display row index# 0 thru 7, but scroll down to row# 99 and display it.

[red]
rowIdx = 99 ' item to scroll to
ctlListName.Selected(rowIdx) = True[/red][green]
' some code here to
' force ctlListName to scroll down
' & put rowIdx at the top of the control[/green][red]
...
[/red]

cheers
L.
 
A Multi Select List Box can't be budged programmatically. This will work for a NON-Multi Select List Box, however.
Put this in the On Current Event for the form.
Code:
Private Sub Form_Current()
  Dim firstValue
  With Me.ctlListName
      firstValue = .ItemData(.ItemsSelected(0))
      .Value = .ItemData(.ListCount - 1)
      .Value = firstValue
    End With
End Sub
Is that any good to you?

A messy workaround could be to create multiple Non-multi listboxes and have each of them use my code above.
Sorry buddy!
 
Thanks.

Multi-select listboxes were the most feasible option for my form. I'm try to create multiple records by 'multiplying' the # of Sizes selected by the # of Colours selected by the # of Destinations.

eg. 10 Sizes(listCtl) x 3 Colors(listCtl) x 4 Destinations(tabCtl, each Dstn has different cost elements) = 120 new records to create...

I was hoping to simplify the GUI appearance when users navigate from one Destination tab to the next - Size/Color lists currently refresh with each tab click. Sometimes the size or color information disappears completely because it is located in a completely different part of the list for different Destinations.

Ah well, back to the drawing board.

cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top