I’m working with BetterListView Express from Component Owl.
in the listView there are 3 columns, FeatureNumber, FeatureName and FeatureCost..
the user can select multiple features, right click on them and buy them,
when the user buys a features, I remove it from the listView,
the problem is that when he selects multiple items and buy them at once,
they get removed one after the other in a very slow motion, lagy manner ..
not just when selecting and buying, but also when the listView shows up at first ..
at first I thought this is due to the listView background image I had..
so I compressed it, but didn’t make that whole lot of difference ..
I even tried to removed the background, still, lagging remained ..
Just in case you wanna know, the font of the available items is Impact with a black forecolor, and the font of the unavailable items is Arial with a DimGray forecolor.
I’m running on a Toshiba Laptop with a Corei3, 2Gigs of Ram and a 1Gig ATI VGA.
This is the code I used to remove the items:
(This is actually a part of it, there are other things that are irrelevant to the list view, like decreasing the Purchaser money and stuff like that .. )
private void purchaseFeatureToolStripMenuItem_Click(object sender, EventArgs e)
{
int NumberOfSelectedItems = listView.SelectedItems.Count;
for (int i = 0; i < NumberOfSelectedItems; i++)
{
int SelectedIndex = listView.SelectedItems[0].Index;
if (Purchaser.Money >= Convert.ToInt16(listView.Items[SelectedIndex].SubItems[2].Text))
{
//this is just to organize the rest of the features numbers.
for (int k = SelectedIndex + 1; k < listView.Items.Count; k++)
{
int NextItemNumber = Convert.ToInt16(listView.Items[k].SubItems[0].Text);
listView.Items[k].SubItems[0].Text = (--NextItemNumber).ToString();
}
listView.SelectedItems[0].Remove();
}
}
}
is there a way to get rid of this lagging ?
or is it because of my specs ?
Any help would be really appreciated ..
ThanX a lot in advance .. 🙂
Before making multiple changes to the control, always call BeginUpdate, then EndUpdate when you are done.
The regular listview would be slow as well, if you didn’t use BeginUpdate/EndUpdate.