Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2003
    Posts
    59

    Unanswered: Formatting list box

    When a list box drops down on a form, the currently-selected item in that list is always at the top of the visible list. Is there a way to put it in the middle, so that items before and after the selected item can be seen?

    Also, is there a way to edit how many items are seen when it drops down?

    Thanks

  2. #2
    Join Date
    Sep 2003
    Location
    Caldes de Malavella, Spain
    Posts
    244
    I assume you mean a Comob Box rather than a List Box.

    To answer your first question: no.

    To answer your second question: it's the "List Rows" property of the Combo Box. It defaults to 8. Don't set it to more rows than you can fit vertically on the screen otherwise....well, try it and see!!

    Hope this helps.
    Andy Briggs
    Elmhurst Solutions Limited
    Database Development and Consultancy
    http://www.elmhurstsolutions.com

  3. #3
    Join Date
    Apr 2003
    Posts
    59
    I did mean a list box, but I assume the answer is still the same?

  4. #4
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Quote Originally Posted by katerpillar
    I did mean a list box, but I assume the answer is still the same?
    I dont understand what you mean by 'drop down' if it isnt a combo box. I would assume the answer is the same but I am not positive.

    What do you mean by drop down maybe help us get a better understanding and possibly help you more.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  5. #5
    Join Date
    Apr 2003
    Posts
    59
    I mean that when you click on the list box then the currently-selected item and a few after it become visible, with a scroll bar down the side.

    It has just occurred to me to tell you that I'm using Access 97 - maybe the list boxes display differently in later versions?

  6. #6
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    I know what you're talking about ... I don't think you can. You'd have to override the control to handle centering of the row ...
    Back to Access ... ADO is not the way to go for speed ...

  7. #7
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    If your List Box is not bound, you can use this little procedure to center the select row. It cheats by selecting the value a specified number of rows before your value and then reselects the correct value.
    Code:
    Sub PositionRow()
    
        Dim intSetBack As Integer
        Dim intCurrent As Integer
        
        If Me.List2.ListIndex > 0 Then
            intCurrent = Me.List2.ListIndex
            If intCurrent > 7 Then ' this assumes the control will fit 7 rows
                intSetBack = intCurrent - 4
            Else
                intSetBack = 0
            End If
            Me.List2 = Me.List2.Column(Me.List2.BoundColumn - 1, intSetBack)
            Me.List2 = Me.List2.Column(Me.List2.BoundColumn - 1, intCurrent)
        End If
    End Sub
    
    Private Sub Text4_AfterUpdate()
    
        Me.List2 = Me.Text4
        Call PositionRow
        
    End Sub
    With some modification, it can probably be adapted to use for bound controls as well - I just cobbed it up quickly on my lunch break.

    Have fun!

  8. #8
    Join Date
    Apr 2003
    Posts
    59
    Thanks a lot everybody!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •