Re: Max number of items in a listbox?
From: Martin (martinvalley_at_comcast.net)
Date: 06/14/04
- Next message: Ken Halter: "Re: MsFlexGrid"
- Previous message: Larry Serflaten: "Re: Writing Files in VB Problem"
- In reply to: Björn Holmgren: "Re: Max number of items in a listbox?"
- Next in thread: Bob O`Bob: "Re: Max number of items in a listbox?"
- Reply: Bob O`Bob: "Re: Max number of items in a listbox?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 14 Jun 2004 10:28:42 -0700
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?
On Mon, 14 Jun 2004 17:04:23 +0200, "Björn Holmgren"
<bjohol@hotmail.com> wrote:
>"Martin" <martinvalley@comcast.net> wrote in message
>news:frerc017sjhrlb0mbkotm677n5ln8pjjf4@4ax.com...
>> Thanks.
>>
>> Yes, I agree regarding UI design. In this instance, I'm using a
>> ListBox as sort of an event log. My program communicates with other
>> devices and I provided some trouble-shooting screens with the logging
>> being able to be turned on and off. It just dawned on me that I'm not
>> limiting the number of entries that can accumulate in this listbox
>> and, if the user were to let it run for a day or so, I could get to a
>> point where the program could crash. I need to add some code to remove
>> entries from the top of the list when the listcount exceeds some
>> number (probably 5000 entries).
>
>
>Ahhh, an event log. Ok, something like this then:
>
>'----------
>Sub AddLogEntry(sText As String, iMaxItems As Integer)
> If List1.ListCount >= iMaxItems Then List1.RemoveItem 0
> List1.AddItem sText
> List1.ListIndex = List1.ListCount - 1
>End Sub
- Next message: Ken Halter: "Re: MsFlexGrid"
- Previous message: Larry Serflaten: "Re: Writing Files in VB Problem"
- In reply to: Björn Holmgren: "Re: Max number of items in a listbox?"
- Next in thread: Bob O`Bob: "Re: Max number of items in a listbox?"
- Reply: Bob O`Bob: "Re: Max number of items in a listbox?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|