The BeginUpdate and EndUpdate methods which are supported by the ComboBox, TreeView, ListBox, ListView, DataGridColumnStyle, ToolStripCombBox (new to 2.0) are a great way to prevent the control from painting until you are finished adding content to them. Take a look at the following code:
for (int i = 0; i < 100000; i++)
{
listBoxIndividuals.Items.Add(“Display Entry ” + i.ToString());
}
The ListBox control will paint each time an item is added to it. This causes flickering, due to the number or repaints, and degrade the performance of your form. If you wrap the above code fragment around a BeginUpdate and EndUpdate method pair the flickering is prevented. The BeginUpdate method stops the control from being repainted and the EndUpdate method resumes the controls painting.
listBoxIndividuals.BeginUpdate();
for (int i = 0; i < 100000; i++)
{
listBoxIndividuals.Items.Add(“Display Entry ” + i.ToString());
}
listBoxIndividuals.EndUpdate();
This method seems to work if you are adding items individually or using Data Binding. If you are adding items individually you might want to think about using the AddRange method which enables you to add an array of items at one time.