W
Wayne Hartell
Hi there,
I have the case where I am trying to optimize some slow code that selects
listBox items.
For approximately 6,500 items, the IndexOf method takes about 3 seconds on a
2.4GHz machine, and SetSelected takes about 9 seconds.
The label lookup from the lable map takes about 0.004 seconds.
Is there any way of selecting items in a quicker, possible batch fashion?
SelectedIndices appears to be read only. Surely it can't take 9 seconds to
select all these indexes when only 10 or 12 are displayed at any one time.
I've tried SuspendLayout() and ResumeLayout() to try to avoid code that
updates the display after every selection, but the performance remained the
same.
for(int i = 1; i <= aenumElements.Count; i++)
{
string alabel = m_idLabelMap[aenumElements] as string;
int aindex = listBoxElements.Items.IndexOf(alabel);
if(aindex >= 0)
listBoxElements.SetSelected(aindex, true);
}
Any tips would be greatly appreciated (short of re-working the use case to
not require 6,500 elements of course).
Thanks,
Wayne.
I have the case where I am trying to optimize some slow code that selects
listBox items.
For approximately 6,500 items, the IndexOf method takes about 3 seconds on a
2.4GHz machine, and SetSelected takes about 9 seconds.
The label lookup from the lable map takes about 0.004 seconds.
Is there any way of selecting items in a quicker, possible batch fashion?
SelectedIndices appears to be read only. Surely it can't take 9 seconds to
select all these indexes when only 10 or 12 are displayed at any one time.
I've tried SuspendLayout() and ResumeLayout() to try to avoid code that
updates the display after every selection, but the performance remained the
same.
for(int i = 1; i <= aenumElements.Count; i++)
{
string alabel = m_idLabelMap[aenumElements] as string;
int aindex = listBoxElements.Items.IndexOf(alabel);
if(aindex >= 0)
listBoxElements.SetSelected(aindex, true);
}
Any tips would be greatly appreciated (short of re-working the use case to
not require 6,500 elements of course).
Thanks,
Wayne.