I can't answer your question. Even if I knew the technology, I might not have an answer that would fulfill your needs. Part of the issue is you are asking "help me solve this in the way I am trying to solve it" rather than "here is the business problem, what is the best solution".
My advice: Go back to the core problem, which sounds like "I need a way of updating a 'list' with new events while keeping the list to 1000 items or less". From this, you have a solution of a ListBox appended to bottom and cleared from top as your solution. And, I am not sure how to turn off scrolling in your solution, but I am not convinced it is the only way to solve the business problem.
Broken down, there are a few questions to answer:
- How do I bind/update the data?
- How do I keep the control from scrolling to a new position when I change the number of items bound?
As far as binding, the programatic addition is one option, whether you add from bottom and prune top or add to top and prune bottom. Another is to assemble the data and rebind. I would imagine there are others.
The scrolling problem is not really a scrolling problem as much as a "remember what I am looking at" problem or a "always display newest" problem. If always display newest, you need to figure out a way to make sure you are at the end when something is added or removed. If user can change position, you need to have a means of storing where he is and getting back to that position. You have added some complexity, as your list can be 1 to 1000 items long, so scroll position, except always at bottom, is dicey, unless you work in percentages. Regardless of whether turning off scrolling solves the immediate problem, if there is a business requirement to remember the user's position, you should have a check step after data is updated.
As a last suggestion, look at how other people have solved the problem of displaying streaming data. Following a well-known pattern is a good idea, as it gives the user a familiar interface. Often, with streaming data, the stream has a very small set of lines (enough to fill a screen, not 1000), but allows you to go back and look at previous "logged" events, if needed. Once again, I am not sure your solution requires a streaming type solution, but you still should go back to the core business problem and start from there.
ListBox.BeginUpdate
before you callRemoveAt(0)
. Then set the selected item to the last one in the list, and finally callEndUpdate
. This should prevent the ListBox from updating untilEndUpdate
is called. – Jim Mischel