Re: Max number of items in a listbox?
From: Bob O`Bob (filterbob_at_yahoogroups.com)
Date: 06/14/04
- Next message: DNagel: "Re: Max number of items in a listbox?"
- Previous message: DNagel: "Re: iis session listener"
- In reply to: Martin: "Re: Max number of items in a listbox?"
- Next in thread: Martin: "Re: Max number of items in a listbox?"
- Reply: Martin: "Re: Max number of items in a listbox?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 14 Jun 2004 11:05:24 -0700
Martin wrote:
>
> I added code as you suggested and it does limit the number of items in
> the list.
>
> However, this "broke" another feature that I had working and I can't
> figure out how to get around it. Perhaps you might have an idea?
>
> I have some code in the program (just after an item is added) that
> causes the list to auto-scroll when an item is added but only when the
> slider bar is all the way down. If the user has scrolled up in to the
> list somewhere and is reading something, the list won't jump back down
> to the bottom when another item is added.
>
> FWIW, this is accomplished with the following statement (constX is set
> at design time and is one greater than the number of items that are
> visible in the list):
>
> If List1.ListCount - List1.TopIndex = constX Then
> List1.TopIndex = List1.ListCount - 1
> End If
>
> What's happening now is, when the .RemoveItem 0 executes, the list
> automatically refreshes and scrolls up no matter what part of the list
> is being viewed.
>
> Do you know if there is any way to keep this from happening?
Of course there is.
First I think I would store the TopIndex before running any append code.
Then you know what it _was_.
I think I would do the above test differently, but yours probably works.
And if the decision is to _not_ set TopIndex to that high value
(to drive the scroll to the max) then you'll want to subtract 1 from
the old TopIndex value for each item was removed.
This of course means that you might sometimes try to set the new TopIndex
to less than zero, but I'd probably ignore that case at first, then
make sure to run specific tests to see if the listbox handles it.
And of course if it doesn't, there's a little more code to write.
Bob
- Next message: DNagel: "Re: Max number of items in a listbox?"
- Previous message: DNagel: "Re: iis session listener"
- In reply to: Martin: "Re: Max number of items in a listbox?"
- Next in thread: Martin: "Re: Max number of items in a listbox?"
- Reply: Martin: "Re: Max number of items in a listbox?"
- Messages sorted by: [ date ] [ thread ]