On Tue, 15 May 2012 10:13:21 +0100, mick wrote:
> [...]
>> How do I do this? Right now, the dialog box is never disposed in the
>> calling procedure. I just have a static variable that holds it, and
>> then I call frmWindow.ShowDialog (this), when I need it. And when the
>> user gives an answer, I call this.Close() to end it.
>>
>> But still there is a pause, and using the debugger, I can see that the
>> dialog box is calling each items ToString() method, so I assume this
>> is being done just to repaint the listbox. Is there a better way?
>
> Have you tried using Hide() instead of Close()?
A modal Form (as here) is only ever actually hidden when the Close() method
is called anyway.
As far as the original question goes: the bottom line is that 6000 items is
a HUGE number of items for any ListBox to contain, and for any user to have
to navigate.
I don't recall seeing any Intellisense window that contained even that
many, never mind "much more than" that many. However, for situations where
this amount of data is going to be displayed (whether it's a good idea or
not...sometimes it is, but more often it's not), the usual approach for
performance is to "virtualize" the display of the items.
That is, rather than having a control that is fully populated with a large
number of items all at once, have a program-maintained data structure
containing just the minimal amount of data necessary (e.g. an array of
strings themselves), and then reference that data structure as needed to
draw the individual items in the control (i.e. rather than expecting the
control to not only maintain the whole list of data items and also to
convert from a non-string object to a string in real-time as the control is
drawn).
At the very least, the OP should populate the ListBox with actual string
objects, not some other object that needs its ToString() method called for
display. And to really handle that number of list items efficiently, they
should look into "owner-draw" items, or even a fully custom implementation
of a list box where they have full control over the entire rendering code
path.
Pete